I am using ViewPager for screen slide it works fine for language's script from left to right but for Arabic script which is actually right to left is not feasible
can i swipe pages of viewpager in reverse order?
Try this,
viewPager.setCurrentItem(ViewPagerSize);
and this will make user swipe right to left
At the time of this post, ViewPager still doesn't handle RTL correctly. Here's a a workaround when using TabLayout:
- Set
android:layoutDirection="ltr"
in the TabLaout XML, so it will always display left-to-right. Before you call
setupWithViewPager(viewPager)
, check if running in RTL, and if so, reverse the order of the tabs, and start with the last tab:if (MyApp.isRTL()) { Collections.reverse(pgAdapter.fragmentList); viewPager.setCurrentItem(pgAdapter.getCount() - 1); }
RTL can be checked using the following code:
public static boolean isRTL() {
final int directionality = Character.getDirectionality(
Locale.getDefault().getDisplayName().charAt(0));
return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT ||
directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
}
Try this but it is not professional
Write this in xml for VeiwPager
android:rotationY="180"
and also in veiw_item
android:rotationY="180"
..
来源:https://stackoverflow.com/questions/22836504/viewpager-for-screen-slides-from-right-to-left