Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable WebView touch events in Android

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.

like image 467
hpique Avatar asked Oct 04 '10 08:10

hpique


2 Answers

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.

like image 115
hpique Avatar answered Nov 16 '22 23:11

hpique


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

like image 31
Octavian A. Damiean Avatar answered Nov 16 '22 22:11

Octavian A. Damiean