在 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屋!
查看全文