I have a view with an onClickListener inside of a scrollview. The view should react on clicks, but the scrollview interpretes almost all touches as ACTION_MOVE and intercepts the touch events, so i cannot click the view.
I have modified my scrollview as follows (because it is in a viewpager and needs to disable scrolling the viewpager)
@Override
public boolean onInterceptTouchEvent(MotionEvent p_event) {
if (p_event.getAction() == MotionEvent.ACTION_MOVE) {
return true;
}
return super.onInterceptTouchEvent(p_event);
}
@Override
public boolean onTouchEvent(MotionEvent p_event) {
if (p_event.getAction() == MotionEvent.ACTION_MOVE && getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(p_event);
}
How can I change the sensitivity of the ScrollView to not register the tiniest movements as ACTION_MOVE and pass the touch events to its children?
thanks for your help!
Nevermind, I fixed it! The first part is not necessary, if you modify the code as follows it works fine:
@Override
public boolean onInterceptTouchEvent(MotionEvent p_event) {
/*if (p_event.getAction() == MotionEvent.ACTION_MOVE) {
return true;
}*/
return super.onInterceptTouchEvent(p_event);
}
@Override
public boolean onTouchEvent(MotionEvent p_event) {
if (p_event.getAction() == MotionEvent.ACTION_MOVE && getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(p_event);
}
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