October 2019
Intermediate to advanced
624 pages
20h 7m
English
To fix this, define a new shape drawable that will be used for the pressed state of the button.
Create button_beat_box_pressed.xml in res/drawable. Make this pressed drawable the same as the normal version but with a red background color.
Listing 22.4 Defining a pressed shape drawable (res/drawable/button_beat_box_pressed.xml)
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/red"/>
</shape>
Next, you are going to use this pressed version when the user presses the button. To do this, you will use a state list drawable.
A state list drawable is a drawable that points to other drawables based on the state of something. A button has ...
Read now
Unlock full access