开发者

Disable WebView touch events in Android

开发者 https://www.devze.com 2023-01-18 11:15 出处:网络
How do you disable all touch events in an Android WebView (or scrolling in particular)? I would like the activity to handle all touch ev开发者_运维技巧ents.mWebView.setOnTouchListener(new View.OnTouch

How do you disable all touch events in an Android WebView (or scrolling in particular)? I would like the activity to handle all touch ev开发者_运维技巧ents.


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.


If I got you right you just have to overwrite the onTouchEvent method.

0

精彩评论

暂无评论...
验证码 换一张
取 消