Android Stack
Android Stack

Reputation: 4314

Double Color Text

i have app include textview , i wonder if i can show the text with double color ,

for changing the color of the text easy to achieve by the following code :

android:textColor="#B22222" 

but what i need to achieve is :

text with two different color

or

text with color filled inside other color

as exampled image below :

enter image description here

so i can apply that to the whole text or part of it inside the textview .

I searced the net for any example but i cant find one ,

any advice will be appreciated , thanks

UPDATE:

Iused shadow in text XML , it gave aclose shape of what im looking for , but not exact double color as previous image ,

my shadow code :

  <TextView   
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:text="hi"  
 android:textStyle="bold"  
 android:textSize="150dp"  
 android:typeface="sans"  
 android:textColor="#0000ff"  
 android:shadowColor="#B22222"   
 android:shadowRadius="2.0"  
 android:shadowDy="10.0" 
 android:shadowDx="10.0"         /> 
<TextView    
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content"   
 android:text="hi"     
 android:textStyle="bold"  
 android:textSize="150dp" 
 android:typeface="sans" 
 android:textColor="#0000ff"  
 android:shadowColor="#B22222"  
 android:shadowRadius="25.0"         />

output result as below image :

enter image description here

Any idea to get same shape of text in first image , thanks

Upvotes: 2

Views: 635

Answers (3)

DynamicMind
DynamicMind

Reputation: 4258

Its working find for me with two color white and red.

TextView textPaint = (TextView) findViewById(R.id.share_button);
        textPaint.getPaint().setShadowLayer(2, 5, 5, Color.RED);

Upvotes: 0

Jumpo
Jumpo

Reputation: 641

I can give some useful Examples. If you can refer this Example to make your own Color and apply shadows for your text. Examples are Text Shadows and TextView. Please refer this link and make your own color and shadow. This answer is very helpful to you.

Upvotes: 0

Diego Torres Milano
Diego Torres Milano

Reputation: 69218

You could probably use shadowColor, shadowDx, shadowDy and shadowRadius to achieve a very similar effect to the first example.

Upvotes: 4

Related Questions