I am trying to hide the toolbar when Webview
is scrolled up and show when the webview is scrolled down. to achieve the behavior i found something called Coordinator Layout. But unfortunately its not working for me.
How my xml looks?
<CoordinatorLayout
-------
<AppBarLayout
-------
<Toolbar
-----
app:layout_scrollFlags="scroll|enterAlways"
------
/>
</AppBarLayout>
<SwipeRefreshLayout
-------------
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/globalWebView"
---------------------------
---------------------------/>
</SwipeRefreshLayout>
</CoordinatorLayout>
Actually when i found its not working i tried in other way that is
<CoordinatorLayout>
<AppBarLayout>
<Toolbar....
app:layout_scrollFlags="scroll|enterAlways"/>
</AppBarLayout>
<WebView...
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</CoordinatorLayout>
But it did not worked for me. is there any solution to make it work? TIA.
Wrap your webView
into NestedScrollView
like below..
<CoordinatorLayout
....>
<AppBarLayout>
<Toolbar....
app:layout_scrollFlags="scroll|enterAlways"/>
</AppBarLayout>
<NestedScrollView
....
...
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView....
... />
</NestedScrollView>
</CoordinatorLayout>
Further, You can use nestedScrollingEnabled(boolean)
of NestedScrollView
as needed.