Android - Shadow on Text

Shadow Effect for a Text in Android?

Perhaps you'd consider using android:shadowColor, android:shadowDx, android:shadowDy, android:shadowRadius; alternatively setShadowLayer() ?

Android - shadow on text?

You should be able to add the style, like this (taken from source code for Ringdroid):

  <style name="AudioFileInfoOverlayText">
<item name="android:paddingLeft">4px</item>
<item name="android:paddingBottom">4px</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:textSize">12sp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">1</item>
</style>

And in your layout, use the style like this:

 <TextView android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/AudioFileInfoOverlayText"
android:gravity="center" />

Edit: the source code can be viewed here: https://github.com/google/ringdroid

Edit2:
To set this style programmatically, you'd do something like this (modified from this example to match ringdroid's resources from above)

TextView infoTextView = (TextView) findViewById(R.id.info);
infoTextView.setTextAppearance(getApplicationContext(),
R.style.AudioFileInfoOverlayText);

The signature for setTextAppearance is

public void setTextAppearance (Context context, int resid)

Since: API Level 1

Sets the text color, size, style, hint color, and
highlight color from the specified TextAppearance resource.

Android How does TextView Shadow work

Please Refer the following link:

http://android--code.blogspot.in/2015/05/android-textview-text-shadow.html

You have to take the 3-4 textview's in yout xml file, then change the shadowDx, shadowDy and color of the shadow for each textview, then you will observe the difference.

How do I Set the Shadow around TextView

Create a new drawable resource file. I named mine two_sided_border.xml.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item>
<shape>
<solid android:color="@color/black" />
</shape>
</item>
<!-- This is the main color -->
<item android:bottom="2dp" android:right="2dp">
<shape>
<solid android:color="@color/green" />
</shape>
</item>
</layer-list>

Then use this as the background for your textview.

<TextView
android:id="@+id/t"
android:background="@drawable/two_sided_border"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>

Your colors and dimensions (padding, text size) can be tweaked to suit.

Two great links:

how to make stroke for 3 sides for a shape in android?

And borrowed some code from here:

Open-sided Android stroke?

ps the other answer provided by Basil Miller gives good way to set shadow for the actual text itself.

textview

How to add shadow to text of a button in android?

The easiest way is

yourButton.setShadowLayer(24,4,4,Color.RED);

The structure of the method is like setShadowLayer(float radius, float dx, float dy, int color)

, dx and dy are x and y offsets of the shadow

How can make Text Shadow in android?

Try below code

 <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:shadowColor="@color/text_shadow"
android:shadowDx="3"
android:shadowDy="3"
android:shadowRadius="5"
android:text="Hello Shadow Text"
android:textColor="@android:color/black"
android:textSize="14sp"
android:textStyle="bold" />

and define color as

  <color name="text_shadow">#58ACFA</color>

how to add shadow on text in android?

Have you tested with the tag text-shadow?

text-shadow: 5px 5px 5px black;


Related Topics



Leave a reply



Submit