gpt4 book ai didi

android - 使可折叠工具栏自动折叠/展开

转载 作者:行者123 更新时间:2023-11-29 14:22:38 31 4
gpt4 key购买 nike

当垂直偏移超过特定阈值时,如何使android中的可折叠工具栏自动折叠/展开?

例如,如果垂直偏移超过 getScrollRange() 的半点,则可折叠工具栏应自动展开,低于该阈值时应折叠。

最佳答案

您可以像下面这样使用 snap 标志:

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

Example Gif

Using this option will determine what to do when a view only has been partially reduced. If scrolling ends and the view size has been reduced to less than 50% of its original, then this view to return to its original size. If the size is greater than 50% of its sized, it will disappear completely.

您可以在此处阅读有关 CollapsingToolbarLayout 的滚动标志的更多信息:
https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout

关于android - 使可折叠工具栏自动折叠/展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39032324/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com