Shape Drawables

Now, make your buttons round with a ShapeDrawable. Since XML drawables are not density specific, they are placed in the default drawable folder instead of a density-specific one.

In the Project tool window, create a new file in res/drawable called button_beat_box_normal.xml. (Why is this one “normal”? Because soon it will have a not-so-normal friend.)

Listing 21.2  Making a round shape drawable (res/drawable/button_beat_box_normal.xml)

<​s​h​a​p​e​ ​x​m​l​n​s​:​a​n​d​r​o​i​d​=​"​h​t​t​p​:​/​/​s​c​h​e​m​a​s​.​a​n​d​r​o​i​d​.​c​o​m​/​a​p​k​/​r​e​s​/​a​n​d​r​o​i​d​"​
 ​ ​a​n​d​r​o​i​d​:​s​h​a​p​e​=​"​o​v​a​l​"​>​

 ​ ​<​s​o​l​i​d​
 ​ ​ ​ ​a​n​d​r​o​i​d​:​c​o​l​o​r​=​"​@​c​o​l​o​r​/​d​a​r​k​_​b​l​u​e​"​/​><​/​s​h​a​p​e​> ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.