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屋!