<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.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/main_drawer"
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:openDrawer=“start”
tools:context=".MainActivity">
//主界面在前,抽屉内容在后
<!--主要内容-->
<include layout="@layout/app_main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!--左滑菜单-->
<com.google.android.material.navigation.NavigationView
android:id="@+id/main_nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
//控制抽屉弹出方向
android:layout_gravity="start"
//导航菜单
app:menu="@menu/activity_main_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>