ScrollFlags共有五种常量值供AppBarLayout的Children View使用,在xml布局文件中通过app:layout_scrollFlags
设置,对应的值为:scroll,enterAlways,enterAlwaysCollapsed,snap,exitUntilCollapsed;也可以在代码中通过setScrollFlags(int)
方法使用
以下文字记录(无效果图)
1.scroll:上滑动时,toolbar隐藏;下滑时先滑动scrollview类似的view,待滚动至顶部时,再滑动toolbar至可见
2.scroll|enterAlways:上滑动时,toolbar隐藏;下滑时先滑动toolbar至可见,再滑动scrollview类似的view
3.scroll|enterAlways|enterAlwaysCollapsed:
需要设置
android:layout_height="@dimen/dp_200"
android:minHeight="@dimen/dp_56"
上滑动时,toolbar隐藏;下滑时先滑动toolbar显示minHeight高度,接着滑动滚动布局显示顶部内容,最后再次滑动toolbar至height设置的高度,并显示标题
4.scroll|exitUntilCollapsed
需要设置
android:layout_height="@dimen/dp_200"
android:minHeight="@dimen/dp_56"
上滑动时,toolbar收缩至minheight,但不隐藏;下滑时先滑动滚动布局显示顶部内容,接着滑动toolbar至height设置的高度,并显示标题
(与3不同的是toolbar不会完全消失)