CoordinatorLayout:隐藏/显示一半可见的工具栏?工具栏、CoordinatorLayout

由网友(搁浅的爱情)分享简介:我还想来达到类似的效果为一个你可以看到在谷歌Play商店,其中通过滚动含量工具栏熄灭-screen为您滚动。 Id like to achieve a similar effect as the one you can see in Google Play store, where by scrolling the...

我还想来达到类似的效果为一个你可以看到在谷歌Play商店,其中通过滚动含量工具栏熄灭-screen为您滚动。

Id like to achieve a similar effect as the one you can see in Google Play store, where by scrolling the content the Toolbar goes off-screen as you scroll.

这工作正常的 CoordinatorLayout (1)在推出的#io15 ,但是:如果停止滚动中途工具栏仍保留在屏幕上,但减少了一半:我希望它关屏动画,就像在谷歌Play商店。我怎样才能做到这一点?

This works fine with the CoordinatorLayout (1) introduced at #io15, however: If you stop the scroll "mid-way" the Toolbar remains on screen, but is cut in half: I want it to animate off-screen, just like in the Google Play store. How can I achieve that?

推荐答案

现在Android的支持库23.1.0有一个新的滚动标记 SCROLL_FLAG_SNAP ,它允许你实现这个的效果。

Now the Android Support Library 23.1.0 has a new scroll flag SCROLL_FLAG_SNAP which allows you to achieve this effect.

AppBarLayout支持一些滚动的旗帜,影响孩子的意见,以滚动(如滚动关闭屏幕)的反应。这次发布的新品是SCROLL_FLAG_SNAP,确保滚动结束时,认为不剩部分可见。相反,它会被滚动到其最近的边缘,使得完全可见或滚动完全在屏幕上。

AppBarLayout supports a number of scroll flags which affect how children views react to scrolling (e.g. scrolling off the screen). New to this release is SCROLL_FLAG_SNAP, ensuring that when scrolling ends, the view is not left partially visible. Instead, it will be scrolled to its nearest edge, making fully visible or scrolled completely off the screen.

阅读全文

相关推荐

最新文章