I'm using support.v4.widget.SlidingPaneLayout
, My app supports two languages, English and Arabic. Android version supported is from 4.2.
For English I'm using default behaviour of SlidingPaneLayout
ie. menu will be at the left and the content frame opens from left to right. When User selects arabic language. I want everything to be from Right to Left (RTL).
Please tell me any tweek to the SlidingPaneLayout
such that in 1 shot I can make it RTL ie. menu on the right Side and content frame opens from right to left.
Thanks in advance.
http://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.html
In order to support RTL in your app, you first need to add android:supportsRtl="true"
to the <application>
element in your manifest file.
Add in SlidingPaneLayout
android:layoutDirection="ltr"
for leftandroid:layoutDirection="locale"
determinate by systemSample: set SlidingPanelLayout in left
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sliding_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layoutDirection="ltr"
tools:context=".MainActivity"
tools:showIn="@layout/app_bar_main">
<fragment
android:id="@+id/panel_left"
android:name="onePanelFragment"
android:layout_width="180dp"
android:layout_height="match_parent"
android:layout_gravity="start" />
<fragment
android:id="@+id/panel_right"
android:name="twoPanelFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_weight="1" />
</android.support.v4.widget.SlidingPaneLayout>
remember that the components inside the SliderLayout will also affect their alignment