如果不需要,防止 CollapsingToolbarLayout 崩溃 [英] Prevent CollapsingToolbarLayout collapse if not needed
问题描述
使用:
编译'com.android.support:design:23.0.0'编译'com.android.support:appcompat-v7:23.0.0'编译'com.android.support:cardview-v7:23.0.0'编译'com.android.support:recyclerview-v7:23.0.0'
随着项目
在 Cheesesquare 中实现此类行为例如,只需将 NestedScrollView 的 android:layout_height
参数修改为 wrap_content
.如果它足够小以适合屏幕,它将阻止按内容滚动.
为了防止通过 CollapsingToolbarLayout
滚动,您应该以编程方式将 layout_scrollFlags
参数设置为 AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP
值.
此处描述了如何执行此操作.
Using:
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
With the project Cheesesquare updated.
Into the detail of cheese, I remove 2 cards (to have only one). Is there a way to prevent the collapsing of the toolbar that show a blank space?
To implement such behaviour in Cheesesquare example just modify android:layout_height
param of the NestedScrollView to wrap_content
.
It will prevent scrolling by content if it is small enough to fit on the screen.
And to prevent scrolling by CollapsingToolbarLayout
you should programmatically set layout_scrollFlags
parameter to the AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP
value.
Here described how you can do this.
这篇关于如果不需要,防止 CollapsingToolbarLayout 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!