图像的可点击区域 [英] clickable area of image
问题描述
我'设计的GUI遥控器,而是让单独的按钮为每个远程按钮,我想获得一个完整的准备远程图像,并设置它的某些部分可点击的。 有没有一种方法,而不是运动事件来做到这一点?
i'am designing a GUI remote control, but instead of making separate buttons for each remote button, i want to get a full ready remote image and set certain parts of it click-able. is there a way rather than the motion event to do this?
推荐答案
我有两个,整个图像保持可点击的,但你可以得到关于点击区域的信息2解决方案,为您的requirement.in。
I have 2 solutions for your requirement.in both,the whole image stays clickable but you can get information about clicked area.
解决方案1:
您可以掩盖的形象,并得到了像素的颜色下面image.so最终你可以来知道哪些地区已经被点击。
you can mask the image and get the pixel color of that underneath image.so ultimately you can come to know which area has been clicked.
在这里,当点击时,你可以检查背景图片
的像素颜色和predefined颜色设置为了解该地区已被点击与之匹敌。
here,whenever clicked occurs,you can check the pixel color of background image
and match it with predefined color set to know about which area has been clicked.
前景图像:
Foreground image:
背景图像:
Background image:
点击区域:
Clickable area:
仍然困惑?
参考: 我想建议你去通过本的教程
Reference: I would like to suggest you to go through this tutorial.
解决方案2:
您可以映射你的形象是坐标,并据此就可以得到已被点击区的信息。
you can map your image with co-ordinates and accordingly you can get the information of area which has been clicked.
例: MappedImage与坐标
如果你不知道的坐标,您可以创建从这里您mappedimage
if you are not aware of co-ordinates,you can create your mappedimage from here
坐标为堪萨斯会是这个样子,
co-ordinates for Kansas will look something like this,
<area shape="poly" coords="243,162,318,162,325,172,325,196,244,196" id="@+id/area14" name = "Kansas"/>
参考: 请看看 Android的图片映射。
我希望这会有所帮助!
这篇关于图像的可点击区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!