亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

DrawerLayout雙抽屜(同時向左和向右抽屜)

DrawerLayout雙抽屜(同時向左和向右抽屜)

冉冉說 2019-12-17 14:43:33
我有一個應用程序,我想在其中實現一個雙抽屜-一個在左邊,另一個在右邊。左抽屜用于應用程序導航,右抽屜用于結果過濾。因此,布局如下所示:<?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”,以及它們各自的重力-“開始”和“結束”,這實際上有效!您可以將它們全部拉出。問題是,當我實現DrawerToggle時-它僅打開左抽屜,而沒有關閉右抽屜,因此,如果右抽屜被打開并且我按DrawerToggle按鈕-左抽屜也將打開,并且與右抽屜重疊。我正在嘗試幾種解決方案:在右側創建相同的DrawerToggle按鈕,其行為和動畫與左側相同。將抽屜放在我要打開的抽屜的另一側-自動關閉(如果左抽屜打開并且我按下右抽屜的扳鈕,反之亦然)。而且我還沒有弄清楚該怎么做,因為DrawerToggle接受DrawerLayout本身作為參數,而不是單個抽屜...我正在使用支持庫。有人有想法么?先感謝您。
查看完整描述

3 回答

?
慕標琳琳

TA貢獻1830條經驗 獲得超9個贊

您可以在ToggleButton的處理程序中這樣調用它,例如:


mDrawerLayout.openDrawer(mDrawer);

mDrawerLayout.closeDrawer(mDrawer);

其中mDrawer是對您需要打開的特定抽屜(是視圖還是布局)的引用,在這種情況下,是您希望顯示的實際ListView。


查看完整回答
反對 回復 2019-12-17
  • 3 回答
  • 0 關注
  • 769 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號