January 2017
Beginner to intermediate
624 pages
22h 42m
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 23.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 xmlns:android="http://schemas.android.com/apk/res/android"
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> ...Read now
Unlock full access