Nested Scrolling support for Android WebView
NestedScrollingWebView
is-a WebView
that implements NestedScrollingChild
.
It is useful for purposes where WebView
is required to be:
- Scrollable
- Zoomable
- Supporting nested scrolling
Example: Hiding the toolbar upon scroll (Issue-14991).
Why: There is no default way to reliably support all the 3 aforementioned behaviors as:
- Using
NestedScrollView
interferes with the zoom (Issue-16135). - Intercepting the scale motion events from
NestedScrollView
and passing it toWebView
is unreliable. - Hiding the toolbar by detecting scroll is unreliable.
- Workarounds for ensuring reliable zoom behavior interferes with scrolling.
- Methods allowing consistent scroll and zoom behavior are not reliable for hiding toolbar.
Usage: Refer the example app in the repo.
WebView.setNestedScrollingEnabled
must be set totrue
. (Example)- XML:
<com.deysak.nestedscrollingwebview.NestedScrollingWebView ... />
(Example)
(A) Infinite Scroll after zoom:
NestedScrollingWebView ✨
new-scroll.mp4
Bug 🐞
old-infinite-scroll.mp4
(B) Unreliable Zoom:
NestedScrollingWebView ✨
new-zoom.mp4
Bug 🐞
Notice that I am trying to zoom at start, but it isn't zooming in.old-buggy-zoom.mp4
So far it has been only tested for the purpose of collapsible toolbar, while allowing for reliable zoom and scroll functionality.