android – 同一个Activity上的两个导航抽屉

前端之家收集整理的这篇文章主要介绍了android – 同一个Activity上的两个导航抽屉前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以在同一活动中配置两个导航抽屉,一个来自左边,另一个来自右边?

解决方法

您可以使用抽屉布局
<android.support.v4.widget.DrawerLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/drawer_layout"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <!-- The main content view -->

   <FrameLayout
      android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
       android:layout_width="240dp"
       android:layout_height="match_parent"
       android:layout_gravity="start"
       android:choiceMode="singleChoice"
       android:divider="@android:color/transparent"
       android:dividerHeight="0dp"
       android:background="#111"/>


   <ListView android:id="@+id/right_drawer"
       android:layout_width="240dp"
       android:layout_height="match_parent"
       android:layout_gravity="end"
       android:choiceMode="singleChoice"
       android:divider="@android:color/transparent"
       android:dividerHeight="0dp"
       android:background="#111"/>
 </android.support.v4.widget.DrawerLayout>

还要检查文档https://developer.android.com/training/implementing-navigation/nav-drawer.html

确保使用工具栏而非操作栏

原文链接:https://www.f2er.com/android/316486.html

猜你在找的Android相关文章