Search code examples
androidwebviewscrollviewtouch-event

How to have vertical scrolling in Webviews that are inside a Scrollview?


I have a Webview that is embedded inside a scrollview. The Webview itself has areas that are vertical scrollable.

Now if I try to scroll inside the webview, the scrollview intercepts the touchevent and scrolls the whole webview instead that only the small scrollable div is moved.

How can I make the scrollview work only if the webview does not want to scroll?


Solution

  • Our solution uses a Javascript callback through the Javascript Interface. Every time a part of the UI that is scrollable inside the WebView is touched a listener is called through java script and this listener calls requestDisallowInterceptTouchEvent on the WebViews parent.

    This is not optimal but the nicest solution found at the moment. If the user scrolls very fast the layer in the WebView won't scroll but at a normal scroll rate it works fine.