我正在进行这个项目,我需要创建一个双抽屉应用程序,可以修改导航抽屉,以便它可以在两侧工作吗?或者我是否在不使用导航抽屉的情况下创建了双抽屉。
答案 0 :(得分:1)
尝试滑动菜单库
SlidingMenu
您必须自己实施按钮功能,但它不应该太难!
编辑:
一个例子:
SlidingMenu menuS = new SlidingMenu(this);
menuS.setMode(SlidingMenu.LEFT_RIGHT);
menuS.setMenu(R.layout.slideout_list);
menuS.setSecondaryMenu(R.layout.slideout_list2);
As the code shows you need to set the mode to LEFT_RIGHT and must specify a layout for both the left menu (setMenu()) and the right menu (setSecondaryMenu()) along with the other options specifying menu size and shadows etc.
答案 1 :(得分:0)
如果你的导航抽屉需要显示不同的数据(为什么你会从右边和左边显示相同的数据?),如左边的导航和右边的搜索过滤器。你最好使用2个不同的抽屉,每个抽屉都有自己的数据/行为。
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
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">
<include layout="@layout/content_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_ad_list"
app:menu="@menu/activity_main_navigation_menu"
headerLayout="@layout/nav_header_ad_list"
menu="@menu/activity_main_navigation_menu"
tools:layout_gravity="start"
/>
<android.support.design.widget.NavigationView
android:id="@+id/activity_main_search_filter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_gravity="end"
tools:layout_gravity="end"
/>
</android.support.v4.widget.DrawerLayout>
答案 2 :(得分:0)
你必须结合一些方法。就像你必须在导航抽屉布局中的导航视图部分中实现片段一样。第二,不能同时打开两个抽屉,因此在那里实现一个片段,并根据不同的点击事件打开具有不同重力值的抽屉布局(GravityCompat.START,GravityCompat.END)。 例如从左侧的抽屉按钮打开抽屉和从右侧打开抽屉的过滤器按钮,并在此基础上加载不同的片段视图。我希望它能满足你的目的。