使用DrawerLayout实现侧拉菜单,简单并且自由度高。
</pre><pre name="code" class="html"><android.support.v4.widget.DrawerLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawerlayout"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="试题列表" android:id="@+id/btn" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/btn" android:layout_centerHorizontal="true" android:layout_marginBottom="74dp" android:id="@+id/main_text" /> <Button android:text="侧拉菜单" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignRight="@+id/btn" android:layout_alignEnd="@+id/btn" android:layout_marginTop="16dp" android:id="@+id/main_cela" /> </RelativeLayout> <RelativeLayout android:id="@+id/left" android:layout_width="250dp" android:layout_height="match_parent" android:layout_gravity="left" android:background="#ff0000"> </RelativeLayout> </android.support.v4.widget.DrawerLayout></pre><pre nam