Check this answer. I think this is related to your question.
For your example, you can have a drawable in your drawable folder. Call it anything. I am calling it button_states.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:drawable="@drawable/cancel" /> <!-- This can be your image -->
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@color/grey" /> <!-- This can be the color you want to show when the button is pressed. Define this in colors.xml -->
<item
android:state_enabled="true"
android:drawable="@drawable/cancel" /> <!-- Use the same image here -->
</selector>
Finally add this drawable as background of your ImageButton. Like this:
<ImageButton
android:id="@+id/imageButtonSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_states" />