I am using a popular solution to circular ViewPager, that is, add two more view in front and last. But it does not slide smoothly between first and last. For example, when we slide right from the last to the first, the scrolling will be cut down once our finger leaves the screen, and the first picture shows immediately.
The reason I find out is that the callback method "onPageSelected" in interface "OnPageChangeListener" was called before the scrolling finished. This is not acceptable, why the new page was selected before the old one vanish?
And now, I have no way to solve this problem. Hope your help!
Following is my code fragment:
@Override
public void onPageSelected(int position) {
if (position == views.size() - 1) {
viewPager.setCurrentItem(1, false);
}
else if (position == 0) {
viewPager.setCurrentItem(views.size() - 2, false);
}
}
Other code may be unneccessary, if you had encountered this kind of question, you will be clear about it.
First time asking a question for me. If anything inappropriate, please tell me, thanks!