ViewPager for screen slides from right to left

送分小仙女□ 提交于 2019-12-07 08:42:31

问题


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?


回答1:


Try this,

viewPager.setCurrentItem(ViewPagerSize);

and this will make user swipe right to left




回答2:


At the time of this post, ViewPager still doesn't handle RTL correctly. Here's a a workaround when using TabLayout:

  1. Set android:layoutDirection="ltr" in the TabLaout XML, so it will always display left-to-right.
  2. 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;
}



回答3:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!