同一活动上有两个导航抽屉 [英] Two Navigation Drawer on same Activity

查看:68
本文介绍了同一活动上有两个导航抽屉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在同一活动中配置两个导航抽屉,一个从左侧配置,另一个从右侧配置?

Is it possible to configurate two Navigation Drawers on the same activity, one from the left and the other from the right?

推荐答案

您可以使用抽屉式布局

 <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

确保您使用的是工具栏而不是操作栏

Make sure you are using toolbar not action bar

这篇关于同一活动上有两个导航抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆