Question

I am trying to make a clickable imageView. For the that I am using invisible buttons on it. But my question is when I click , I want to avoid touching on an empty area or other clickable part since the shape is not linear. How can I do that?

Was it helpful?

Solution

You should not use an invisible button to do that, you are just drawing several times the same pixels for nothing, and this will lead to poor performance.

What you can do is make your ImageView clickable (as @shkschneider told you) and use the ImageView's onClickListener methods to handle the onClick behaviour (the same way you would do with a button).

EDIT :

If I understood well, you're looking for a way to set several clickable areas among one ImageView. In that case, here is a good tutorial about it.

OTHER TIPS

Don't use a Button, use an ImageView made clickable.

<ImageView android:clickable="true"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top