Skip to content
Advertisement

How can I give an imageview click effect like a button on Android?

I have imageview in my Android app that I am using like a button with the onClick event given, but as you might guess it is not giving imageview a clickable effect when clicked. How can I achieve that?

Advertisement

Answer

You can design different images for clicked/not clicked states and set them in the onTouchListener as follows

JavaScript

The better choice is that you define a selector as follows

JavaScript

and select the image in the event:

JavaScript
Advertisement