How do you disable all touch events in an Android WebView (or scrolling in particular)? I would like the activity to handle all touch events.
A:
If I got you right you just have to overwrite the onTouchEvent method.
Octavian Damiean
2010-10-04 09:04:24
Most likely that should work. I was wondering if there was a property or something more straightforward than that.
hgpc
2010-10-04 09:09:29
Ah I see well then you might want to try to give your WebView this layout parameter android:clickable="false". I'm not sure if it works but theoretically it should as WebView is inherited from View.
Octavian Damiean
2010-10-04 09:14:16
Doesn't work but I've found another solution which I posted.
hgpc
2010-10-04 14:30:59
+2
A:
mWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
Disables all touch events on a WebView
because the touch listener is executed before the default touch behavior of the WebView
. By returning true
the event is consumed and isn't propagated to the WebView
.
Using android:clickable="false"
does not disable touch events.
hgpc
2010-10-04 14:30:09