布局
使用的控件是:
android.support.v4.widget.DrawerLayout
主界面的布局
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="cfeng.cn.com.dralayoutmenu.MainActivity"
tools:openDrawer="start">
<include layout="@layout/app_bar_main"></include>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"
/>
</android.support.v4.widget.DrawerLayout>
@layout/app_bar_main 是显示的主界面
android.support.design.widget.NavigationView 是侧滑界面容器
android:layout_gravity="end"
android:layout_gravity="end" 是抽屉的打开方向
问题我想做一个新的需求 :侧滑界面不和这个一样怎么办呢?
没办法只能够写在 @layout/nav_header_main 可以自定义布局