1

I have got an image with different arbitrary shaped portions in it.

enter image description here

Now I want to show some data when clicked in the particular portion of the Image. e.g. When I click in the portion A, I want to show a notification with name of the portion.

I don't have idea on how to achieve this task. Please guide me on this.

Khawar
  • 5,197
  • 4
  • 28
  • 52

1 Answers1

2

Try to add an OnTouchListener to get the coordinate where your image gets touched. With these coordinates you could match the shape what is clicked.

Thkru
  • 4,218
  • 2
  • 18
  • 37
  • kudos and upvotes are appreciated ;) see http://stackoverflow.com/questions/3476779/how-to-get-the-touch-position-in-android for further informations – Thkru Jun 07 '12 at 15:01
  • But how to identify that in which potion I have clicked? e.g. how do I know that I have clicked in boundary A? – Khawar Jun 08 '12 at 11:59
  • That's just about some calculations and visual computing... follow the edges, get the coordinates of each boundary and process it. – Thkru Jun 08 '12 at 12:10
  • @ThomasK : I encounter same problem as this question.So this is fine but what if screen size changed by using another device? Then Entire calculation will be go in vain. Is it right? Thanks. – Ponting Aug 28 '13 at 14:23
  • You could use different mappings, depending on the resolution/size of your device. Furthermore you could do this using views where every view has its own listener. – Thkru Aug 28 '13 at 15:30