I have found a solution if I use code.
In layout in element CollapsingToolbarLayout
you can use the properties app:expandedTitleTextAppearance
and app:collapsedTitleTextAppearance
but a perculity can not be directly assigned the color, before you must define the styles
in styles.xml
define
<style name="ExpandedToolbar" parent="@android:style/TextAppearance">
<item name="android:textColor">@android:color/transparent</item>
<item name="android:textSize">32sp</item>
</style>
<style name="CollapsedToobar" parent="@android:style/TextAppearance">
<item name="android:textColor">@android:color/white</item>
</style>
And now in CollapsingToolbarLayout
we assign
app:expandedTitleTextAppearance="@style/ExpandedToolbar"
app:collapsedTitleTextAppearance="@style/CollapsedToobar"
We will get the effect fadeOut
to expand and fadeIn
when the toolbar collapses
In java code, it is not how it is done, if someone wants to complement it, edit the answer.
Update
I see that the color at @color:android/transparent
of white turns to gray before fade, the reason is that transparent = #000000
to solve that, if the text of the bar is white its transparent is #00FFFFFF