Android Material Design - CollapsingToolbarLayout 折叠后如何更改工具栏的背景颜色 [英] Android Material Design - How to change background color of Toolbar after CollapsingToolbarLayout is collapsed
问题描述
在用户向下滚动屏幕后,CollapsingToolbarLayout 中的图像消失,留下一个带有后退按钮、内容标题和设置菜单的工具栏.我想知道如何仅在折叠"状态下更改该工具栏的背景颜色.
After the user scrolls down the screen, the image in the CollapsingToolbarLayout disappears and is left with a toolbar with the back button, content title, and settings menu. I want to know how to change the background color of that toolbar only when its in a 'collapsed' state.
我所指的操作与工具栏背景颜色变为绿色的类似:
The action I am referring to is similar to this where the toolbar background color changes to green:
在 CollapsingToolbarLayout 下面我有一个 NestedScrollView 和 CardViews
Below the CollapsingToolbarLayout I have a NestedScrollView with CardViews
推荐答案
我认为您在追求 app:contentScrim
.
<android.support.design.widget.CollapsingToolbarLayout
...
app:contentScrim="?attr/colorPrimary">
<!-- Toolbar and ImageView here -->
</android.support.design.widget.CollapsingToolbarLayout>
这篇关于Android Material Design - CollapsingToolbarLayout 折叠后如何更改工具栏的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!