I am writing application that uses ViewPager
to host Fragment
s.
When I change fragment programmatically the smooth scroll function does not work. I use ViewPager.setCurrentItem(int item, boolean smoothScroll)` method.
Maybe anyone know a workaround this bug? Maybe with animations?
EDIT:
I am using support package. And the issue is that whether I use ViewPager.setCurrentItem(2, true)
or ViewPager.setCurrentItem(2, false)
the result is the same. The view switches really fast (not smoothly).
I've fixed this by creating a MyViewPager that overrides the ViewPager.mScroller using reflection.
What worked for me was to call mPager.setCurrentItem after the mPagerAdapter.notifyDataSetChanged(), and not as a posted runnable.
Here is an example (in MonoDroid):
where
and