2016-06-16 55 views
0

我正在爲我的活動在景觀佈局工作。在景觀活動中,我碰巧有下面的xml代碼的佈局。DrawerLayout結束重力。抽屜不作爲孩子邊緣滑動打開

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" android:layout_width="wrap_content" 
    android:layout_height="match_parent"> 
    <FrameLayout 
     android:layout_width="200dp" 
     android:background="@android:color/holo_blue_bright" 
     android:layout_height="match_parent"/> 
    <android.support.v4.widget.DrawerLayout 
     android:layout_width="200dp" 
     android:layout_height="match_parent"> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:background="@android:color/darker_gray" 
      android:layout_height="match_parent"/> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_gravity="end" 
      android:background="@android:color/holo_red_light" 
      android:layout_height="match_parent"/> 
    </android.support.v4.widget.DrawerLayout> 
</LinearLayout> 

這裏出現的問題是抽屜沒有通過邊緣滑動打開。順便說一句,使用LTR佈局,所以最終是正確的。通過用於打開抽屜的java調用,抽屜打開並且觸摸事件也被處理。所有抽屜也都是解鎖的。但是當Drawer佈局是水平方向的線性佈局的子項時,Drawer不會從右邊緣滑動打開。如果linearLayout中的第一個Frame:ayout寬度爲零,則抽屜工作。

抽屜佈局有什麼問題?我怎樣才能解決這個問題?

回答

0

從Android參考:

DrawerLayout充當窗口內容

一個頂層容器的DrawerLayout需要是視圖的根元素。它不能嵌套在LinearLayout