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
- and what the view pager does is to switch the tabs: for example first tab is the index, second is map, etc.
The problem is that if, being the first tab chosen, I click on the fourth tab, I can see how the ViewPager
goes through the second and third tab and stops on the fourth, and I don't want that to happen.
I tried to disable all the animations for this ViewPager
trying to use a setAnimation
to null
every time the user chooses a new tab to be displayed, but it still doesn't work.
Any idea to achieve this, please? Thanks a lot in advance!
EDIT: I also tried to override onCreateAnimation
for each Fragment
but still not working
setCurrentItem(position) with an extra parameter to false , which is the smooth scroll for the ViewPager . After this, the scroll will be done without any smoothing and thus the animations won't be seen.
A simple solution is to create your own subclass of ViewPager that has a private boolean flag, isPagingEnabled . Then override the onTouchEvent and onInterceptTouchEvent methods. If isPagingEnabled equals true invoke the super method, otherwise return .
I finally found out: the issue can be solved by just calling the mViewPager.setCurrentItem(position)
with an extra parameter to false
, which is the smooth scroll for the ViewPager
. After this, the scroll will be done without any smoothing and thus the animations won't be seen.
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