1

I have this image:

enter image description here

And I need to be able to create custom buttons on it if possible. The islands are the buttons.

We have tried working with shapes but weren't able to implement it and we couldn't find anything concrete online.

Can anyone help us out or point us to a good tutorial/explanation?

Thanks!

Ed Holloway-George
  • 5,092
  • 2
  • 37
  • 66
Bram-N
  • 426
  • 4
  • 15
  • http://stackoverflow.com/questions/13763545/android-maps-api-v2-with-custom-markers http://stackoverflow.com/questions/14811579/how-to-create-android-map-api-v2-custom-marker-with-imageview https://developers.google.com/maps/documentation/android-api/marker?hl=en – Chaudhary Amar Jan 04 '16 at 09:33
  • Check out this http://stackoverflow.com/questions/13861416/android-custom-shape-button – Rahul Kumar Jan 04 '16 at 09:36
  • @AmarbirSingh If I've read correctly that only applies to actual google maps? – Bram-N Jan 04 '16 at 09:43
  • @RahulKumar That solution doesn't apply here since the buttons will then overlap :/ – Bram-N Jan 04 '16 at 09:44
  • Okay. Did u try with markers ? – Rahul Kumar Jan 04 '16 at 09:45
  • Not yet, Amarbir linked me to that but don't they only apply to actual google maps? I'll read into it some more – Bram-N Jan 04 '16 at 09:49
  • Take a Button give the background as your island(iimage) and put your another image in android:drawableRight/Left etc..(as you want) – Chaudhary Amar Jan 04 '16 at 09:49

1 Answers1

0

Create custom ImageView, where you will preload the image and implement onTouchListener. There you can implement logic for handling click events. To make it super easy you can create alpha mask for each button and in onTouchListener verify if in the specific (x,y), which button has been clicked, then add animation and so on. Unfortunately it needs to be done "by hand".

  • Won't it look if you've clicked in a square with coordinates (x,y)? Or can I give a whole range of points in which it has to check? – Bram-N Jan 04 '16 at 10:02
  • You can do whatever you want and it won't look like you clicked on a square. Simply combine with alpha masks for each button to recognize clicks and play with the code to show click events, eg you can use the same mask to lighten the color on the selected tile. – Szymon Klimaszewski Jan 04 '16 at 12:40
  • Sorry I worded that badly, I meant that the created button (visible or not) will still be a square, right? So if the user presses on the edge of an island it wont work because the buttons (shape) can't go outside of the island because that would give problems – Bram-N Jan 04 '16 at 13:07
  • No, no, the idea is different. Please take a look at this super pro alpha mask of your first button: http://imgur.com/GkAZpfV let's assume that white=0=false and black=1=true, the mask has the same size as your original bitmap and with that you can catch hits with perfect precision. Do you get the idea now? – Szymon Klimaszewski Jan 04 '16 at 13:30
  • Aha okay, thanks a lot! I'll comment tomorrow if it worked or not :-) – Bram-N Jan 04 '16 at 13:42