直接上代码
布局文件:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- main layout must be the first one layout -->
<!-- using background to devide -->
<RelativeLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
</RelativeLayout>
<!-- drawer layout -->
<!-- layout_gravity="start": means to show it from left to main position -->
<!-- 240dp is lower than all phones width -->
<!-- using background to devide -->
<!-- 如果不写gravity=start的布局,代表没有左侧抽屉 -->
<RelativeLayout
android:id="@+id/drawer_left"
android:layout_width="240dp"
an