1

我在我的應用程序中使用SlidingPaneLayout。
在橫向方向上,我希望SlidingPaneLayout的左右窗格完全吻合,並且不需要滑動即可查看它們。
我的佈局:橫向SlidingPaneLayout不滑動

<android.support.v4.widget.SlidingPaneLayout 
     android:id="@+id/sliding_pane_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/header" > 

     <ListView 
      android:id="@+id/left_drawer" 
      android:layout_width="220dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:background="@color/tab_normal_bg" 
      android:choiceMode="singleChoice" 
      android:divider="@drawable/tab_divider" 
      android:dividerHeight="1dp" /> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="1000dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" /> 

    </android.support.v4.widget.SlidingPaneLayout>  

任何幫助將非常感激。
謝謝!

回答

0

設置content_frame寬度爲 「match_parent」

<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" /> 
+0

這不起作用。我已經試過了。 –

-1

的content_frame應當具有寬度=爲600dp。 它在平板電腦風景模式下工作。

+0

但面板仍然滑動 –

+0

這將在橫向模式下工作,在縱向上它將保持滑動功能 – Phuong

0

有兩種方法可以實現的是:

如果你不關心的寬度和你只是有興趣在景觀並排顯示的看法方面:

定義爲橫向模式不同的佈局(在名爲layout-landscape的目錄中)定義了相同的子元素,但低於水平LinearLayout。

如果你有,你會多少DPS標記爲不滑動窗格斷點近似:

添加android:layout_weight="1"到的FrameLayout,因爲根據文件,這將適合由兩種觀點留下的任何空間。換句話說,如果兩個視圖的寬度之和小於可用的屏幕寬度,則第二個視圖會填充左側留下的空間。