I am using an ImageButton
. But I don get the highlight when clicked. I googled and many suggested to use selector where another image is displayed. Is there any way
This is actually not very difficult to do. You don't even need to create 2 seperate .png files or anything like that. For instance, if you want to have a button which has a gradient, and then change it when the button is pressed:
Step 1: Create default button gradient (drawable/default_button.xml):
Step 2: Create default button pressed gradient (drawable/default_button_pressed.xml):
Step 3: Create selector (drawable/default_button_selector.xml):
Step 4 (optional): Create style for the button (values/style.xml):
Step 5: use the button (layout/main.xml):
As you can see, it's not particularly difficult to do.