1.首先要替换掉原先的主布局

android.support.v4.widget.DrawerLayout

2.定义一个id
侧拉框
3.写一个布局
侧拉框
4.然后找到主键
5.给它写一个监听(new一个新的监听)
侧拉框
布局代码

<android.support.v4.widget.DrawerLayout 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/dl"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/colorAccent"
    android:orientation="vertical"
    >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:layout_gravity="center_horizontal"
        android:src="@mipmap/ic_launcher_round"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:text="宋小宝"
        android:layout_gravity="center_horizontal"
        android:textSize="20sp"
        />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

相关文章:

  • 2021-09-16
  • 2021-05-10
  • 2021-04-17
  • 2021-11-27
  • 2021-10-25
  • 2021-12-08
  • 2022-12-23
猜你喜欢
  • 2021-11-10
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2021-12-11
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案