制作一个图像分成几个图像按钮 [英] Making one image into several image buttons

查看:145
本文介绍了制作一个图像分成几个图像按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经问过这个问题,但没有得到任何良好的反馈,所以我再次张贴,试图获得更多的帮助。

I asked this question once before, but didn't get any good feedback, so I'm posting it again to try to get more help

好吧,我正在用这种盘在它的应用程序: HTTP ://dl.dropbox.com/u/8051037/disk_full.png

Ok, I'm making an app with this kind of of disk in it: http://dl.dropbox.com/u/8051037/disk_full.png

我有两个环作为单独的图像,但我需要找出一种方法来定位他们就像他们在图像中,第一关。我在搞清楚布局不是很大,所以我真的不知道从哪里开始与该

I have the two rings as separate images, but I need to figure out a way to position them like they are in the image, first off. I'm not great at figuring out layouts, so I don't really know where to start with that.

另外,我需要由黑线限定的每个部分是一个不同的ImageButton。我一直在到处寻找一个答案,但没有人能够帮助我至今。

Also, I need each section defined by the black lines to be a different imagebutton. I've been everywhere looking for an answer to this, but no one's been able to help me so far.

感谢您的帮助,一直停留在这个问题上,现在几个月!

Thanks for any help, been stuck on this problem for a few MONTHS now!

编辑:为了使我的问题有点更清晰,我会充分解释我在做什么。我正在做发射器的修改,使它有点像托尼·斯塔克的电话从钢铁侠2,像这样:的 http://perceptionnyc.com/sites/default/files/D_01_PDA_flat_01.jpg

To help make my problem a bit more clear, I'll fully explain what I'm doing. I'm making a launcher modification to make it kinda look like Tony Stark's phone from Iron Man 2, like this: http://perceptionnyc.com/sites/default/files/D_01_PDA_flat_01.jpg.

(原题:<一href=\"http://stackoverflow.com/questions/5385033/how-make-one-image-into-multiple-buttons-and-some-other-stuff\">How做一个形象成多个按钮和一些其他的东西)

推荐答案

您最好的最好的是创造的形象作为一个单一的视图,重写<一个href=\"http://developer.android.com/reference/android/view/View.html#onTouchEvent%28android.view.MotionEvent%29\"相对=nofollow> onTouchEvent() 方法和呼叫 .getX() .getY()的事件。然后,你可以决定在哪里被点击了一些简单的数学。

Your best best would be to create the image as a single view, override onTouchEvent() method, and call .getX() and .getY() on the event. Then you can determine where was clicked with some simple math.

这将导致比试图创建多个重叠视图和非矩形按钮的更好的解决方案。

This will result in a much better solution than trying to create multiple overlapping views and non-rectangular buttons.

修改的:

由于(X,Y)就可以计算出在哪里点击了利用勾股定理得到斜边的长度(对于这圈里有人点击)并获得使用角度谭 1 (OPP / ADJ)(为此扇形被点击)。

Given (x, y) you can calculate where the click was using the Pythagorean theorem to get the length of the hypotenuse (for which circle was clicked) and get the angle using tan-1(opp/adj) (for which pie slice was clicked).

仅供参考,(X,Y)中的图片说明实际上是从图像的中心各自的差异,而不是值的getX()的getY()直接

FYI, the (x,y) noted in the picture would actually be the respective difference from the center of the image, NOT the values of getX() and getY() directly.

<一个href=\"https://github.com/AnderWeb/android_packages_apps_Launcher/blob/eclair/src/com/android/launcher/ColorPickerDialog.java#L168-212\"相对=nofollow>这是被用于ADW.Launcher圆形拾色器类似code的例子。

这篇关于制作一个图像分成几个图像按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆