CollapsingToolbarLayout淡出动画速度

19

有没有办法编辑CollapsingToolbarLayout的动画速度?我的意思是,当向下滚动时,视图被折叠后的淡出动画。

1个回答

41

您可以使用以下代码(以毫秒为单位):

app:scrimAnimationDuration="600"

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

                ...

</android.support.design.widget.CollapsingToolbarLayout>

另请参见: https://developer.android.com/reference/android/support/design/widget/CollapsingToolbarLayout.html#setScrimAnimationDuration(long)


有没有完全禁用它的方法,让我随心所欲地更改它? - android developer
2
要禁用动画,您必须删除 app:contentScrim="?attr/colorPrimary" - Henrique
1
在可折叠工具栏中,使用“app:scrimAnimationDuration="0"”可以完全移除淡出动画。 - Viral

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接