I have an application in which I want to implement a double box - one on the left and one on the right. The left box is for navigating applications, the right box is for filtering results.
So the layout is this:
<?xml version="1.0" encoding="utf-8"?> <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"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/light_grey" android:orientation="vertical"> <GridView android:id="@+id/gridview" style="@style/GridViewStyle" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:horizontalSpacing="7dp" android:stretchMode="columnWidth" android:verticalSpacing="7dp" /> </LinearLayout> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#111" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" /> <ListView android:id="@+id/right_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="end" android:background="#111" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" /> </android.support.v4.widget.DrawerLayout>
Here you can clearly see the "left_drawer" and "right_drawer", and their gravity is the "beginning" and "end", and it really works! You can pull them both out.
The problem is that when I implement DrawerToggle - it only opens the left drawer and does not close the right one, therefore, if the right drawer is open and I click the DrawerToggle button - the left drawers open ALSO and the right drawer overlaps.
There are several solutions that I am trying to get:
- Make the same DrawerToggle button on the right side, with the same behavior and animation as the left side.
- Make a drawer on the opposite side of the drawer that I am trying to open - it automatically closes (if the left drawer is open and I press the switch on the correct drawer and vice versa).
And I did not understand how to do this, because DrawerToggle accepts DrawerLayout itself as a parameter, and not individual boxes ...
I am using the support library.
Does anyone have any idea? Thank you in advance.
android navigation-drawer drawerlayout
ExiRouS Jul 25 '13 at 15:05 2013-07-25 15:05
source share