Search code examples
androidbuttonmappingareaclickable

Android - How to select the clickable area of a button?


I have an ImageButton with a big image background. I want to be able to set a mapping area in that button, so I have control of the area that will call the onClick method of that button.

In other words, what I need is something similar to the "map" tag of HTML (http://www.w3schools.com/tags/tag_map.asp):

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap" />
<map name="planetmap">
 <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun" />
 <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury" />
 <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus" />
</map>

Is there any way to do that on Android?

Thank you in advance!


Solution

  • Take a look at android-how-to-make-a-clickable-map-image


    And here is a project AndroidImageMap: An implementation of an HTML map like element in an Android View: