I have an ImageButton and I want to make it so the button background changes color when the button is pressed. I have copied the button_bg.xml file from this question.
button_bg.xml looks like this:
<?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 line #54 looks like this:
<ImageButton
android:id="@+id/sendButton"
android:background="@drawable/button_bg"
android:src="@drawable/ic_action_send_now"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:layout_alignParentRight="true" />
I have tried removing the line:
android:background="@drawable/button_bg"
which stops the application crashing but the buttons don't change color.
Any help would be appreciated