I am trying to create a Velocity View Pager where in I can scroll through pages like a gallery view. I am experiencing problem while doing scrolling calculations. I am using FragmentStatePagerAdapter for ViewPager. For a normal first time run things are cool with getScrollBy returning the actual scroll position taking 1st element at 0. i.e. if I am at 3rd page, getScrollX returns 2400(800px per page) and so on.
Problem arises when I get the fragment that hosts viewpager after a resume from backstack. This time my 3rd page becomes 0 and my first page becomes -2400 position. Some how when android reinflates the adapter it considers current position as 0. I have tried all sorts using setCurrentItem everywhere I could. Some how I feel computeScroll does not work.
It would be great if any one can suggest how can I make the getScrollX return the position considering start as 0 and not the newly inflated current position.
Else I would have no option to create a new fragment everytime I resume.