[英]Coordinator Layout Behavior Not Working
I am trying to hide the toolbar when Webview
is scrolled up and show when the webview is scrolled down. 当
Webview
向上滚动时,我试图隐藏工具栏;当Webview
向下滚动时,我试图显示工具栏。 to achieve the behavior i found something called Coordinator Layout. 为了实现这种行为,我发现了一种称为协调器布局的东西。 But unfortunately its not working for me.
但不幸的是它不适用于我。 How my xml looks?
我的xml看起来如何?
<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.
TIA。
Wrap your webView
into NestedScrollView
like below.. 将您的
webView
包装到NestedScrollView
如下所示。
<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. 此外,您可以使用
nestedScrollingEnabled(boolean)
的NestedScrollView
需要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.