I have the following XML code in res/drawable
and I set button background
to this drawable
. However when I pressed the button it is not not changing the color
. Thanks for help
<item android:state_enabled="false"
android:drawable="@color/colorAccent">
</item>
<item android:state_enabled="true"
android:drawable="@color/colorPrimary">
</item>
<item
android:state_selected="false"
android:state_pressed="true"
android:drawable="@color/black">
</item>
This will change the button color on button press.
Order matters when specifying the selector fields - whichever selector it matches first, going from top to bottom, will be the one displayed. The default button state should always be specified last.