文章目录
前言
提示:以下是本篇文章正文内容,下面案例可供参考
一、应用的侧边栏常见地点?
当我们不需要跳转实现复杂的界面更换时,侧边栏可以轻松的解决这些问题。
例如QQ的主页点击个人头像实现的个人中心侧边栏。
二、读入数据
1.首先定位res文件夹的layout文件夹,将activity_main.xml的界面添加按钮命名为button,并使用include布局实现侧边栏界面的占用,并在include中添加具体的xml文件实现界面:
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- 按钮功能-->
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constr