O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Layer List and Inset Drawables

The stock Android buttons you saw in the initial version of your app had a shadow effect. Unfortunately, shape drawables have no shadow property. But you can make the shadow effect yourself using two other XML drawable types: layer list drawables and inset drawables.

Here is how you will do it. First, you will create a shadow with the same shape as your current button drawable. Then you will combine it with the current button using layer-list, and offset the bottom edge of the button a tad using inset so that the shadow becomes visible underneath.

Create a new XML file in res/drawable/. Name it button_shape_shadowed.xml and make its root element layer-list.

Listing 25.8  Normal button shadows (drawable/button_shape_shadowed.xml ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required