Search code examples
androidwebviewscrollpanning

Unexpected scroll on single touch after panning in Android WebView


I have extended WebView and I have enabled zooming with myWebView.getSettings().setSupportZoom(true);.

When I tap the screen (single tap/touch) after I have panned, the WebView seems to move (scroll) to an other position. This messes up my panning and double tap events, because the coordinates change unexpectedly.

Is there a way to prevent this? Android version is 2.3.


Solution

  • The root cause seems to be that the onScroll event is fired.

    I've found a workaround by setting a boolean to false in every method (except onScroll) of my class that extends SimpleOnGestureListener, and then checking that boolean in onScroll. If it's false, then I return true to indicate that the event has been consumed.