在Android中禁用WebView触摸事件 [英] Disable WebView touch events in Android
本文介绍了在Android中禁用WebView触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何禁用Android WebView中的所有触摸事件(或特别是滚动)?我希望该活动能够处理所有触摸事件.
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.
推荐答案
mWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
禁用WebView
上的所有触摸事件,因为在WebView
的默认触摸行为之前执行了触摸侦听器.通过返回true
,事件将被使用,并且不会传播到WebView
.
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
.
使用android:clickable="false"
不会禁用触摸事件.
Using android:clickable="false"
does not disable touch events.
这篇关于在Android中禁用WebView触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文