I need to synchronize scrolling in two viewpagers.
Here some relevant code:
super.onTouchEvent(ev);
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mViewPager.beginFakeDrag();
return true;
case MotionEvent.ACTION_MOVE:
mViewPager.fakeDragBy(mViewPager.getScrollX()-getScrollX());
return true;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mViewPager.endFakeDrag();
return true;
default:
break;
}
return mViewPager.onTouchEvent(ev);
I`m getting touch event, and scrolling the second view by the same amount. But one thing I can't manage is to disable or handle fling similarly, I mean short fast gestrue which automaticaly makes scroll jump to next page.
Structure is -ViewPagerNavigator- -ViewPagerMenu-
How do I make fling in it to work on menu pager, or just disable it?
As per earlier commment:
I'm not sure it'll make a difference, but have you played around with the ViewPager.OnPageChangeListener interface? In stead of capturing the touch event directly, I imagine you could use the onPageScrolled(...) method and the passed in offset. For flings you might be able to get away with onPageSelected(...).
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