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 ...

Get Android Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.