Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Material Design - How to change background color of Toolbar after CollapsingToolbarLayout is collapsed

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:

enter image description here

Below the CollapsingToolbarLayout I have a NestedScrollView with CardViews

like image 754
Eli Davila Avatar asked Jun 03 '15 12:06

Eli Davila


People also ask

How to change background color of collapsing toolbar in Android?

getColor(R. color. my_color_id)); It worked for me and changed the color of the collapsingToolbar once it was collapsed to help me fit the main color of an image that was displayed when the collapsingToolbar was full scale.

How do you change the color of the tool bar on Android?

Just go to res/values/styles. edit the xml file to change the color of action bar.

What is collapsing toolbar Android?

Android CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar. It is designed to be used as a direct child of a AppBarLayout. This type of layout is commonly seen in the Profile Screen of the Whatsapp Application.


1 Answers

I think you're after app:contentScrim.

<android.support.design.widget.CollapsingToolbarLayout     ...     app:contentScrim="?attr/colorPrimary">     <!-- Toolbar and ImageView here --> </android.support.design.widget.CollapsingToolbarLayout> 
like image 73
Jimeux Avatar answered Oct 21 '22 08:10

Jimeux