Disable WebView touch events in Android

后端 未结 2 1909
我在风中等你
我在风中等你 2020-12-01 06:32

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.

相关标签:
2条回答
  • 2020-12-01 06:54
    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.

    0 讨论(0)
  • 2020-12-01 06:58

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

    0 讨论(0)
提交回复
热议问题