State List Drawables
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 (
<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 ...