I want to be able to prevent a user from being able to scroll in my Android ScrollView, but still detect when they tap a button that is within the scroll view.
I've subclassed the ScrollView class and have been fiddling around with the onInterceptTouchEvent
and onTouchEvent
methods, but can't seem to get it quite right. The code below stops the scrolling, but seems to disable tap (but not all, like if you go up and down without any move it works, but if your finger moves slightly as you tap it doesn't register). I've also just removed the onInterceptTouchEvent
as well which almost works, but the scrollview still scrolls as the user removes their finger.
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { App.log("onInterceptTouchEvent, with action : " + ev.getAction()); switch(ev.getAction()) { case MotionEvent.ACTION_MOVE: return true; } return super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { App.log("onTouchEvent, with action : " + ev.getAction()); switch(ev.getAction()) { case MotionEvent.ACTION_MOVE: return false; } return super.onTouchEvent(ev); }