开发者

android ImageView hyperlink coords

开发者 https://www.devze.com 2023-04-08 07:48 出处:网络
I want to implement a functionality in which when particular area of an image set in an ImageView will result in calling an intent.

I want to implement a functionality in which when particular area of an image set in an ImageView will result in calling an intent.

Similar to HTML coords hyperlinks

<img src ="planets.gif" width="145" height="126" alt="Planets" usemap ="#planetmap" />

<map name="planetmap">
   <area 开发者_Python百科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>

I want to implement this even in an zoomed image.

Heres what I have search and found leads on:

I will have to use an SurfaceView with appropriate logic in onTouch();

Similar functionality is there on mapViews get projection method. similar to that but should be to a bitmap loaded.


Another possible approach is create yourself a view that uses a transparent 9 patch as its background. Set it to whatever size and position you need and call your intent from its onClickListener(). This is achieve the same effect from the users perspective.

Edit: If you want multiple active at the same time you'd have to use multiple transparent views. If you only want 1 active at a time you could reuse the same one and just change the size / position of it.

Since using this approach will create extra views you are going to take a slight performance hit. If you are looking to maximize preformance doing something like you've mentioned above where you attach an OnTouchListener and have your logic inside the onTouch callback. You could creat Rect objects to represent your touch areas and call Rect.intersect() to see if the touch event position intersects one of your rect areas. This would likely give you better overall performance.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号