如何通过轮廓的多边形来设置按钮?安卓 [英] How to set button by a contour polygon? Android

查看:608
本文介绍了如何通过轮廓的多边形来设置按钮?安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个相邻的图形按钮。如果我使用的坐标的计算方法,轻触的TouchEvent ,我要创建一个大阵的坐标。也许还有另一种方法?

There are two adjacent graphic buttons. If I use the method of calculation of the coordinates touch TouchEvent, I have to create a large array of coordinates. Maybe there is another method?

推荐答案

可能不是最好的解决办法,但你可以重叠两个按钮每次重新presenting的图像(黑色或白色)的一部分,使其他地区在按钮的形象透明(图像将有两个按钮相同的尺寸)。您还需要延长按钮类重写的onTouchEvent 方法如何处理触摸事件,根据点触摸发生的是一个透明点或图像点。我做了一个小样本项目获得按钮两部分,如下面的(忽略我的设计技能):

Probably not the best solution but you could overlap two buttons each representing a part of the image(the black or white) and make the rest of the Button's image transparent(the images will have the same dimensions for both buttons). You'll also need to extend the Button class to override how the onTouchEvent method handles the touch events, depending on the point where the touch happened being a transparent point or an "image" point. I've made a small sample project obtaining a Button with two parts like below(ignore my design skills):

您可以在这里找到项目,这是pretty的自我解释。看它是否可以帮助你。

You can find the project here, it's pretty self explanatory. See if it helps you.

这篇关于如何通过轮廓的多边形来设置按钮?安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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