1

I'm using the SlidingPaneLayout in my application.
In the landscape orientation I want the left and right panes of the SlidingPaneLayout to fit entirely and no swipe should be required to view them.
My layout is:

    <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>    

Any help would be much appreciated.
Thank you!

Zeba
  • 3,041
  • 1
  • 28
  • 39

3 Answers3

0

Set the content_frame width to "match_parent"

<FrameLayout
  android:id="@+id/content_frame"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_weight="1" />
Ran Dahan
  • 11
  • 3
0

There are two ways to achieve that:

If you don't care about width and you're just interested in displaying views side by side in landscape:

Define a different layout for landscape mode (in a directory called layout-landscape) defining the same children but below an horizontal LinearLayout.

If you have an approximation of how many dps you'll mark a breakpoint for not sliding panes:

Add the android:layout_weight="1" to the FrameLayout, because according to documentation, this would fit any space left by the two views. In other words, if the sum of the two view's widths is less than the available screen width, the second view fills any space left at the right.

-1

The content_frame should have width = 600dp. It work when on tablet landscape mode.

Phuong
  • 1,153
  • 1
  • 10
  • 17