我有一個(gè)應(yīng)用程序,我想在其中實(shí)現(xiàn)一個(gè)雙抽屜-一個(gè)在左邊,另一個(gè)在右邊。左抽屜用于應(yīng)用程序?qū)Ш?,右抽屜用于結(jié)果過(guò)濾。因此,布局如下所示:<?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>您可以在此處清楚地看到“ left_drawer”和“ right_drawer”,以及它們各自的重力-“開(kāi)始”和“結(jié)束”,這實(shí)際上有效!您可以將它們?nèi)坷?。?wèn)題是,當(dāng)我實(shí)現(xiàn)DrawerToggle時(shí)-它僅打開(kāi)左抽屜,而沒(méi)有關(guān)閉右抽屜,因此,如果右抽屜被打開(kāi)并且我按DrawerToggle按鈕-左抽屜也將打開(kāi),并且與右抽屜重疊。我正在嘗試幾種解決方案:在右側(cè)創(chuàng)建相同的DrawerToggle按鈕,其行為和動(dòng)畫(huà)與左側(cè)相同。將抽屜放在我要打開(kāi)的抽屜的另一側(cè)-自動(dòng)關(guān)閉(如果左抽屜打開(kāi)并且我按下右抽屜的扳鈕,反之亦然)。而且我還沒(méi)有弄清楚該怎么做,因?yàn)镈rawerToggle接受DrawerLayout本身作為參數(shù),而不是單個(gè)抽屜...我正在使用支持庫(kù)。有人有想法么?先感謝您。
3 回答

慕標(biāo)琳琳
TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊
您可以在ToggleButton的處理程序中這樣調(diào)用它,例如:
mDrawerLayout.openDrawer(mDrawer);
mDrawerLayout.closeDrawer(mDrawer);
其中mDrawer是對(duì)您需要打開(kāi)的特定抽屜(是視圖還是布局)的引用,在這種情況下,是您希望顯示的實(shí)際ListView。
- 3 回答
- 0 關(guān)注
- 766 瀏覽
添加回答
舉報(bào)
0/150
提交
取消