I have an app with two activities extends same abstract - one with WebView, another with ViewPager with TabLayout and RecyclerViews - and on this level I've implemented "shared" showing/hiding toolbar with scroll/fling feature:
app:layout_scrollFlags="scroll|snap|enterAlways"
WebView is "pushing out" Toolbar just like RecyclerView under any tab in ViewPager (keeping TabLayout visible), in both cases any scroll to top brings back Toolbar. Just like on this example:
Now I've to change this behavior - Toolbar should be hidden when user is NOT on top of page, so: any scroll to bottom should hide Toolbar if present and only (scroll to top && getScrollY()<=0) should make Toolbar enter:
I've borrowed GIFs from THIS guide, which is suggesting (all other too) that my desired behavior is default with just scroll flag (and possibly snap). So I've removed enterAlways and my "native" Activity started to work as intended out-of-the-box. WebView - no change at all...
I'm suspecting that this bug is caused by my NestedWebView, I'm currently using THIS one. So I've tried to drop-in replace this class with these:
marshi - not scrollable webview content (toolbar shows/hides)
takahirom - toolbar enters even when 1px scroll in up direction almost immediate (kind of snap behavior, but during touch)
hanks - no nested scrolling (fixed toolbar), also with uncommented setNestedScrollingEnabled(true); line
How to achieve second GIF Toolbar behavior cooperating with WebView?


read edit on bottom and other answers/comments! don't use this class, also avoid
WebViewin any form if you can. You will get into trouble sooner or later, maintainingWebViewis hell...I've found few different implementations of
NestedWebViewand noticed that all of them are old and implementsNestedScrollingChildwhen currently we have 3rd version of this interface:NestedScrollingChild3(androidx). So I've penetrated current version ofNestedSrcollViewand I've added some new methods handling, and now it works. To be exact - I was trying to achieve smooth scroll through whole screen just like whenWebViewwould fill whole screen andToolbarwas part of web content (always on top). Alsosnapis working. use wiselyedit: this class have a huge flaw! this
Viewconsumes all scroll events dispatching them toToolbar,Coordinatoror it own BUT never ever for nested-scrolling div/view inside HTML content. e.g. if you have own implementation of drop down list (or any self-scrolling view) it wont be scrolled by finger, all events consumed by native views... I've ended up throwing this class away and all nested-scrolling features related to f**kingWebView