Disabling animation in ViewPager

后端 未结 4 1620
猫巷女王i
猫巷女王i 2020-12-04 23:09

I\'d like to disable all the animations for the transitions in my custom ViewPager. This view pager contains four tabs -and each tab loads a Fragment

4条回答
  •  既然无缘
    2020-12-05 00:00

    In the tabselected listener, just set the second argument of the setCurrentItem to false to disable the smooth scrolling.

    mBottomNavigation.setOnTabSelectedListener((position, wasSelected) -> {
    
    
           switch (position) {
                case 0:
                    viewPager.setCurrentItem(0, false);
    
                    return true;
                case 1:
                    viewPager.setCurrentItem(1, false);
    
                    return true;
                case 2:
                    viewPager.setCurrentItem(2, false);
    
                    return true;
            }
            return false;
        });
    

提交回复
热议问题