Development issue/problem:

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?

Classification:

Configure the header of CollapsingToolbarLayout in the activity :

CollapseToolbarLayout collapseToolbar =
(CollapseToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapseToolbar.setTitle(A title here;)

Edit:

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?

Solution 1:

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 :

scrim_top.xml

and scrim_bottom.xml

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 :

#260000
#0C0000
#2A000000
#0D00000000

And for the dimensions I used a height of 88 inches.

Solution 2:

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:

Solution 3:

Edit:

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!

Solution 4:

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
CODE>>.

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:

Extended title

b) If you delete ToolbarLayout, the title will be compressed when scrolling up:

Abbreviation

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.

Give here a description of the image

PS, please update or ask for more information in case of confusion.

Good luck!

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

You May Also Like

Lenovo launches consumer-friendly IdeaPad Chromebooks for Leading a Simpler Hybrid Work Life

Lenovo’s line of consumer-friendly Chrome OS-based laptops may have been a bit…

How to install printer driver without admin rights

I was shocked to find out that most people do not know…

Detailed SiteChecker Pro Review 2021 With Pros & Cons

SiteChecker Pro is an SEO software that helps you find out how…

Jane’s Detective Stories: Detective &amp Match 3 Game For PC (Windows 10, 8, 7)

Jane’s Detective Stories is a fun adventure and puzzle game in which…