Milad Na
Milad Na

Reputation: 53

how can I create a custom clickable shape on an image in android?

I want to create a clickable image, my image has some different clickable parts in it, like this one:

I want to draw a custom shape like : A,B,C,D,E,F and make sure when user click on of this something happen. the problem is I don't have any kind of idea to, how create shapes like the shapes in the image make sure it just fix on the image and in different screen size don't see a massed up thing.

Upvotes: 2

Views: 1878

Answers (2)

VizGhar
VizGhar

Reputation: 3128

Will there be more than many of such images?

If no I suggest you to create mask image for each region where black part of image represents the region and white part excludes rest.

To draw image:

To handle click events:

To optimise:

  • create mask image downscaled by some scale factor
  • during comparison divide touch position by scale factor

This is not ideal, but solution with vectors is non trivial I think

Upvotes: 2

Mayur R. Amipara
Mayur R. Amipara

Reputation: 1223

Take it as image and setOnclickListner for that image

Upvotes: 1

Related Questions