Daniel, how are you?
Follow the link from the official Google documentation regarding this feature. It explains well what each attribute does and gives an example at the end. Here are some excerpts from the page:
Create the file res / color / button_text.xml with the content below.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ffff0000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff0000ff"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
And here is an example implementation, note that in the android:textColor
attribute we refer to the res/color/button_text.xml
we did above:
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button_text"
android:textColor="@color/button_text" />
Documentation page link here.