I would like my Button to draw with a transparent background by default, to draw with a dark blue background when pressed, and to draw with a light blue background when selected. I set the Button’s background to the below selector, and am calling Button.setSelected(!Button.isSelected()) when the button is clicked. The pressed state works properly, but the Button draws with a transparent background when selected.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/tranpsshape" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/tranpsshape" />
<item android:state_pressed="true" android:drawable="@drawable/pressedbuttonshape" />
<item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/selectedshape" />
<item android:state_enabled="true" android:drawable="@drawable/tranpsshape" />
<item android:state_focused="true" android:drawable="@drawable/tranpsshape" />
<item android:state_selected="true" android:drawable="@drawable/selectedshape" />
<item android:drawable="@drawable/tranpsshape" />
</selector>
selectedshape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#A3DAF2"/>
</shape>
pressedbuttonshape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#4ABDE8/>
</shape>
tranpsshape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#00000000"/>
</shape>
Accordind to documentation
So you need to place
state_selectedabovestate_focused. So your file will look like this