Minimize a toolbar using textShadow

I have a problem with a crumbling toolbar, in the advanced state I want a blurry shadow under the text, I use this code:

collapsingToolbar.setExpandedTitleTextAppearance(R.style.toolbar_text); 

from:

 <style name="toolbar_text"> <item name="android:textColor">@color/white</item> <item name="android:shadowColor">@color/black</item> <item name="android:shadowDx">2</item> <item name="android:shadowDy">2</item> <item name="android:shadowRadius">4</item> </style> 

I can change the textColor , it works, but the shadow does not work. I tried many different values ​​for the shadow.

Is it possible to cast a shadow on minimized text? Because in bright images, the title is sometimes difficult to read.

+8
android collapsingtoolbarlayout
source share
3 answers

Instead of using text shadow, use text protection. See this question: Android CollapsingToolbarLayout Background Name

+5
source share

It seems like this is not possible with the support version of lib version 22.2.1 .

Here's a compiled method for setting the appearance of the text:

 void setExpandedTextAppearance(int resId) { TypedArray a = this.mView.getContext().obtainStyledAttributes(resId, styleable.TextAppearance); if(a.hasValue(styleable.TextAppearance_android_textColor)) { this.mExpandedTextColor = a.getColor(styleable.TextAppearance_android_textColor, 0); } if(a.hasValue(styleable.TextAppearance_android_textSize)) { this.mExpandedTextSize = (float)a.getDimensionPixelSize(styleable.TextAppearance_android_textSize, 0); } a.recycle(); this.recalculate(); } 

And it sets only the color and size of the text.

UPDATE: since you mentioned that you need to add a shadow to the title to make it easier to read on light backgrounds, I suggest you change the color of the extended title to a darker shade. For example.

 collapsingToolbar.setExpandedTitleColor(0x000); 
+1
source share

I have a text shadow using the following code. I used FrameLayout at ImageView position, and FrameLayout has both ImageView and View with gradient background.

  •   <ImageView android:id="@+id/groupIcon" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:scaleType="centerCrop" android:src="@drawable/drawer_header_background" app:layout_collapseMode="parallax" /> <View android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/coll_toolbar_image_gradient" /> </FrameLayout> 

coll_toolbar_image_gradient.xml

 <gradient android:angle="90" android:centerColor="#00ffffff" android:endColor="#aa000000" android:startColor="#aa000000" /> <corners android:radius="0dp" /> 

0
source share

All Articles