0

I got struggle with SlidingPaneLayout. I'm trying to create activity with 3 panels like is shown on image: enter image description here

The case is that I want to panel 2 was visible by default, and when user swipe from left to right should open panel 1 and when swipe from right to left panel 3. When I add views to SlidingPaneLayout the last added is visible by default. Is any way to set which view should be starting view? Here's my layout xml:

<android.support.v4.widget.SlidingPaneLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/side_menu_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="@color/gray"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/oliveGreen">
    </LinearLayout>
    <ListView android:id="@+id/right_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_marginRight="0dp"
        android:layout_marginEnd="0dp"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="@color/gray"/>
</android.support.v4.widget.SlidingPaneLayout>

At this configuration rightDrawer is show as starting view. I want to show LinearLayout and set rightDrawr on the right side of it. I hope I made that clear and I would appreciate for any help. Thank you in advance.

mlethys
  • 436
  • 9
  • 29

2 Answers2

0

edit:

I've just re-read the docs for SlidingPaneLayout, and it seems that it's meant for only 2 views.

You might try to fake this layout by using a ViewPager and use the float getPageWidth(int) from the adapter to make pages 0 and 2 smaller. Not sure if that will fit your requirements.

Besides that the only thing you could do is to check the SlidingPaneLayout source code and modify it to make it work with left/right gravity like the drawer does.

original answer

not sure I understand your problem, maybe you expect it to behave differently.

You just use gravity to tell which side the panels will be:

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

   <View android:gravity="left" />
   <View android:gravity="right />
   <View  /> << that's the one always visible.

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

like this.

Budius
  • 39,391
  • 16
  • 102
  • 144