I have a conflict between a ScrollView and a ViewPager.
I’m trying to do something along the lines of
If user clicks ViewPager:
Disable ScrollView
If user releases ViewPager:
Enable ScrollView
I’ve already got the disable/enable code working, but I can’t get the click/release code working.
I’ve tried using OnTouch, as so..
pager.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN){
scroller.setScrollingEnabled(false);
}
if (event.getAction() == MotionEvent.ACTION_UP){
scroller.setScrollingEnabled(true);
}
return true;
}
});
..but this seems to disable the ViewPager from scrolling left and right. Am I using it wrong?
Is there any other alternative to detect presses and releases? Also I’m trying to get it to work on Android 2.1 and higher, so OnDrag doesn’t seem compatible.
Description of the return value for OnTouch()-method to the OnTouchListener interface:
OnTouchListener documentation
Try to return true only for Action of type ACTION_DOWN or ACTION_UP, false otherwise.