Disabling animation in ViewPager

后端 未结 4 1621
猫巷女王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条回答
  •  萌比男神i
    2020-12-05 00:03

    Here's another solution:

    • Subclass the ViewPager (your custom ViewPager)
    • Override the two setCurrentItem methods

    Code Snippet:

    @Override
    public void setCurrentItem(int item, boolean smoothScroll) {
        super.setCurrentItem(item, false);
    }
    
    @Override
    public void setCurrentItem(int item) {
        super.setCurrentItem(item, false);
    }
    

    By setting smoothScroll to false, you're disabling the scroll animation.

提交回复
热议问题