CollapsingToolbarLayout - setting expandTitleTextAppearance and collapsedTitleTextAppearance can cause problems

In the design support library (V 22.2.0), I am having problems setting the expandTitleTextAppearance and collapsedTitleTextAppearance properties for CollapsingToolbarLayout.

For example, if I install it like this:

<android.support.design.widget.CollapsingToolbarLayout android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:expandedTitleTextAppearance="@style/TransparentText" > 

and the styles are as follows:

 <style name="TransparentText"> <item name="android:textColor">#00000000</item> </style> <style name="GreyText"> <item name="android:textColor">#666666</item> </style> 

The text does not appear, but when I try to expand the toolbar after smoothing it, the application crashes on Android 4.1.

And if I installed it like this:

 app:expandedTitleTextAppearance="@style/TransparentText" app:collapsedTitleTextAppearance="@style/GreyText" 

It no longer crashes, but the text does not appear when it crashes.

+5
source share
1 answer

It looks like the styles used to set expandTitleTextAppearance and collapsedTitleTextAppearance should extend from TextAppearance .

So, everything will work correctly if the styles are changed:

 <style name="TransparentText" parent="@android:style/TextAppearance"> <item name="android:textColor">#00000000</item> </style> <style name="GreyText" parent="@android:style/TextAppearance"> <item name="android:textColor">#666666</item> </style> 
By the way, since TextView works correctly when you install android: TextAppearance without explicit @android: style / TextAppearance extension, I registered this as an error: https://code.google.com/p/android/issues/detail?id=178674
+18
source

All Articles