July 2015
Beginner to intermediate
600 pages
18h 59m
English
BeatBox is looking good. You now have round buttons and they visually respond to presses. Time for something a little more advanced.
Layer list drawables allow you to combine two XML drawables into one. Armed with this tool, add a dark ring around your button when in the pressed state.
Listing 21.7 Using a layer list drawable (res/drawable/button_beat_box_pressed.xml)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="oval">
<solid
android:color="@color/red"/>
</shape>
</item>
<item>
<shape
android:shape="oval">
<stroke
android:width="4dp"
android:color="@color/dark_red"/>
</shape>
</item>
</layer-list>
You specified two drawables in this layer list ...
Read now
Unlock full access