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:
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With