Inset TextView shadows

If you’re used to using Apple products, you’re probably familiar with the heavy use of inset shadows. It adds a bit of depth to the UI and can really make the screen look beautiful. Notice the white drop shadow in the title of the window.

Finder

I tend to do the same thing a lot for my Android apps. It’s incredibly simple to do. Here’s an example of a TextView with the same inset shadow.

<!-- Semi-opaque white inset shadow beneath the text -->
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ...
    android:shadowColor="#88FFFFFF"
    android:shadowRadius="0.1"
    android:shadowDx="0"
    android:shadowDy="1" />
       
<!-- Semi-opaque black inset shadow above the text -->
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ...
    android:shadowColor="#88000000"
    android:shadowRadius="0.1"
    android:shadowDx="0"
    android:shadowDy="-1" />

And here’s how it looks:

Inset shadows

It should look great on all screen sizes. Don’t use the above code strictly, however. Mess around with the color values and shadowRadius value to get the exact effect you’re looking for.

This entry was posted in Android. Bookmark the permalink.

2 Responses to Inset TextView shadows

  1. James McMinn says:

    A screenshot of the effect in action (on Android) might be a nice addition. I’m interested how this will looker on smaller, higher DPI screens.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>