How to show SlidingPaneLayout at right side? How to show SlidingPaneLayout at right side? android android

How to show SlidingPaneLayout at right side?


In your manifest, add the following attribute to the opening <application> tag.

android:supportsRtl="true"

Then add this attribute to the opening SlidingPaneLayout tag in your layout.

android:layoutDirection="rtl"

And finally, move the tool_bar <include> element into the main content LinearLayout within the SlidingPaneLayout, and adjust the ImageView's height and weight.

<LinearLayout    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="#101010"    android:orientation="vertical">    <include        android:id="@+id/tool_bar"        layout="@layout/toolbar_layout">    </include>    <ImageView        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:background="@drawable/android_robot" /></LinearLayout>

Please note that the child Views of the SlidingPaneLayout will inherit the rtl layoutDirection. This may cause problems in child Views if their layout behavior is affected by the direction. For example, a horizontally-oriented LinearLayout will lay out its children starting from the right. This is easily remedied by setting android:layoutDirection="ltr" on the affected Views.

Also note that this example hard codes the direction in the layout. If you need to support both LTR and RTL layouts application-wide, you'll need to do this programmatically, accounting for the device's default direction.