Problem: I want to change the background color of a button after clicking it.
This is a simple problem, but I spent a lot of time searching on Google and I cannot find a solution. They all refer to the same XML as shown below.
My XML is as follows:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/black_button_pressed" android:state_focused="true" />
<item android:drawable="@drawable/black_button_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/black_button_normal"/>
</selector>
So, when a person hangs over a button, it becomes gray. When a person presses a button, the shutter background should be grayed out after clicking, but I don’t see it being grayed out. After printing, it returns to normal.
Do you have any tips and / or pointers to help me?
source
share