0

I am using this layout for a two panel UI :

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.SlidingPaneLayout
    android:id="@+id/sp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/leftPane"
        android:name="com.sample.SearchFragment"
        android:layout="@layout/search_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        >
    </fragment>


    <fragment
        android:id="@+id/rightPane"
        android:name="com.sample.DetailFragment"
        android:layout="@layout/detail_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        >
    </fragment>

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

Problem is, the rightPane is always showing up as maximised at the start, I want the left to show first, if I swap them around then the left shows first but the swipe works in the wrong direction.

I would like it to be like the Hangouts app. Which setting do I change?

I want it to show up at the start like so :

 +---------------------+---+ 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 +---------------------+---+ 
sprocket12
  • 5,368
  • 18
  • 64
  • 133

1 Answers1

1

Call showPane() on the SlidingPaneLayout, such as in onCreate() of your activity, just after calling setContentView(). I am not aware of a way to express this solely in the layout file.

FWIW, here is a sample project showing this use of showPane(), plus BACK button handling (if right pane is showing, BACK should show the left pane, per the classic master-detail pattern style).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491