I work with the CollapsingToolbarLayout program of the new Android Design Support Library.
I installed it and it works fine, the only problem I have left is that the text is lost when scrolling, depending on the background image.
What I would like to do is set the background of the CollapsingToolbarLayout header, but I haven’t found a way to do it yet.
Is there anything to make that happen?
Configure the header of CollapsingToolbarLayout in the activity :
CollapseToolbarLayout collapseToolbar =
collapseToolbar.setTitle(A title here;)
Here you can see the screen order when I remove the toolbar. You can see that the header is unreadable. The problem is that I have no control over the images shown, so for some images it looks good and for others, like this example, it looks bad and can’t be read. What I meant was that you might want to add some kind of background for the text, so that the back of the text is always the same color and it’s always legible.
How can I solve this problem?
Use the text protection scream (scroll down a bit). My example assumes that the title text is white, and that some nuance may be needed to optimize it in your case.
Add in your CollapsingToolbarLayout the following after ivBigImage :
Add to the Drawable folder :
For the paints you have to make these shades when you test them for the first time, so it is more obvious that it works, but for the production, I used :
And for the dimensions I used a height of 88 inches.
Use the text saver from the Amagi82 example and add the app:expandedTitleTextAppearance parameter to the CollapsingToolbarLayout.
For example, add the following to your xml style:
If you want to change the color of the toolbar after it has been resized, you must lower the contentScrim attribute in the layout of the toolbar to this color:
If you set the value of this attribute to the color for which you want to change the toolbar, it will solve your problem, as I understand it.
I hope it answers your question!
It takes a lot of work to write such a large piece of code.
I’ve accomplished this in two ways.
1 Easy bypass thanks to the transparent black appearance
Explanation of the code :
1 The CollapsingToolbarLayout style only has the text size.
2 By default, the value in the lower field CollapsingToolbarLayout is replaced by 16dp.
3. Our head with Parallax collapseMod is RelativeLayout with ImaveView and View.
4. This single view with BG at the bottom of the top relative title of the layout with a contrasting color (here #770000), serves as BG for the reduced title of CollapsingToolbarLayout in white.
Images for Style 1 :
a) CollapseToolbarLayout completely reduces the title of the layout:
b) If you delete ToolbarLayout, the title will be compressed when scrolling up:
2 Reply above
The method has already been mentioned by João Ferreira.
This is what it looks like with shadowRadius=16: Watch out for The Shadow.
PS, please update or ask for more information in case of confusion.
collapsingtoolbarlayout android example,android collapsing toolbar,android collapsing toolbar with image,android collapsing toolbar with search,how to change background color of collapsing toolbar in android,android collapsing toolbar with custom toolbar,collapsing toolbar with navigation drawer android example,how to set title in collapsing toolbar