Wednesday, February 23, 2011

Drop shadow text

Here's a little tip for creating a decent drop shadow effect in a TextView.

The issue I ran into initially when trying the shadow effects on TextView is that I could rarely get it to look right - instead of a clean, single pixel shadow, it'd always come out fuzzy. It turns out that the secret is that shadowRadius can be a float, and that you should make that float very small. Here's an example style you can apply to TextViews:

<style name="GreyEtchedText">
<item name="android:textColor">#2F3541</item>
<item name="android:shadowColor">#88FFFFFF</item>
<item name="android:shadowRadius">.1</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">1</item>
</style>

Of course, you can use whatever colors you want for the foreground/shadow.

2 comments:

  1. Saw this same one elsewhere, but alas, it is only for API 11+.

    Cheers, hope all is well.

    ReplyDelete
  2. coding school online for kids I would like to say that this blog really convinced me to do it! Thanks, very good post.

    ReplyDelete