There is an issue in view pager while using the RTL.
According to the right-to-left UI paradigm (RTL) a swipe from left to right should scroll page N to page N+1. Currently ViewPager keeps the common LTR swiping direction (a swipe from right to left scrolls page N to page N+1) even if the current locale is an RTL one (Arabic, Hebrew).
So in this blog, we have shown you how to make your Viewpager swipe direction from right to left when your current local is RTL.
So It is the very simple technique to change the swipe direction of the Viewpager.
- In order to support RTL in your app, you first need to add to android:supportsRtl=”true” the element <application> in your manifest file.
XML Layouts
You’ll need to make the following changes in all your Layouts
- If your app only supports, API ≥ 17 replace all the or layout_marginLeft/layout_marginReft/paddingLeft/paddingRight any other Left and Right layout property with Start and equivalent End. For example, android:paddingLeft will be replaced with android:paddingStart
- If your app supports then API<17 instead of replacing the Left and Right layout properties, add their Start and End layout property equivalent alongside.
I would recommend you check your app once after applying this change as you might not want all your Layouts/Views to be RTL. If you want to force any layout to LTR then just add android:layoutDirection=”locale” to that view.
Like:
1234567 <android.support.v4.view.ViewPagerandroid:id="@+id/view_pager"android:layout_width="match_parent"android:layout_height="match_parent"android:animateLayoutChanges="true"android:background="@color/background_color"android:layoutDirection="locale"/>
So It will work perfectly in ViewPager. No need to rotate the directions.
Old:
There are two simple step which has to follow you,
Step 1. Change the rotation of the View pager,
1 viewpager.setRotationY(180);
Step 2. Then again change the direction of the fragment container which is the child of Viewpager,
1 recyclerView.setRotationY(180);
Note: In my case, I have used Recyclerview as the child of the view pager.
Some Talks by https://code.google.com/p/android/issues
Cheers Coders.