Skip to content

Android TextView Shadow

How to add a shadow in a text view? How to improve the text readability on widgets?

There’s four properties on TextView related to shadows.

First a a normal TextView XML declaration.

<TextView
android:text="I thought what I'd do was, I'd pretend I was one of those deaf-mutes."
android:gravity="center_horizontal"
android:textColor="#000000"
android:layout_width="200px"
android:layout_height="fill_parent">
</TextView>

Now the same TextView with the four shadow properties, the color, the x,y offset and the blur radius.

<TextView
android:text="I thought what I'd do was, I'd pretend I was one of those deaf-mutes."
android:gravity="center_horizontal"
android:textColor="#000000"
android:layout_width="200px"
android:layout_height="fill_parent"
 
android:shadowColor="#555555"
android:shadowDx="5.0"
android:shadowDy="5.0"
android:shadowRadius="3.0">
</TextView>

Published inenglish

One Comment

  1. Vikram Vikram

    The graphics preview in the layout editor may not be accurate:
    * Paint.setShadowLayer is not supported.

    I am getting d above error wen i executed d code of textview shadow
    Kindly provide a solution
    Thanks in advance

Leave a Reply

Your email address will not be published.