Drawlayout
DrawerLayout 最好放在根布局,DrawerLayout之下有两个子布局,一个是FramLayout和TextView
第一个子布局则是主界面布局,第二个子布局则是侧滑的菜单界面
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout android:id="@+id/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:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.us.androiddesign.drawerLayout.DrawerLayoutActivity"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@android:color/holo_green_light" android:theme="@style/Theme.AppCompat.Light.NoActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat"> </android.support.v7.widget.Toolbar> </FrameLayout> <TextView <!--第二个子布局可以选择其他的,比如ListView等--> android:id="@+id/chehua" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#fff" android:layout_gravity="start" <!--这里特别注意这个属性必须要,否则侧滑菜单用不了--> android:text="这是一个侧滑菜单1"/> </android.support.v4.widget.DrawerLayout>