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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
If I got you right you just have to overwrite the onTouchEvent method.