I work in search engines with high and low efficiency to solve this problem ... I tried to override ontouchevent, etc.
I decided that this is the best solution for me (and less hacks). it was easy to implement the maximum or minimum tracker and set it to the current page
maxPageToScroll = viewPager.getCurrentItem(); minPageToScroll = viewPager.getCurrentItem();
and then add the "onPageSelected" method:
public void onPageSelected(int position) { if (position < minPageToScroll) { viewPager.setCurrentItem(maxPageToScroll); } else if (position > maxPageToScroll) { viewPager.setCurrentItem(maxPageToScroll);
therefore, under the conditions, you simply increase maxpage by one.
maxPageToScroll = viewPager.getCurrentItem() + 1;
note that this does not prevent the user form from scrolling ... it just prevents the page view pager from viewing.
source share