有没有一种方法来创建Android上的三角按钮? [英] Is there a way to create a triangular button on Android?
问题描述
有没有一种方法我可以创建其形状为三角形按钮? 我知道我可以把一个三角形图像作为背景,但是这样会让三角形可点击以外的区域。 有没有一种方法来赛格按钮角X和Y,所以我可以使它三角形?
Is there a way I can create a button which is shaped as a triangle? I know I can put a triangle image as background, but this will make the area outside the triangle clickable. Is there a way to sey the button corners X and Y so I could make it triangular?
推荐答案
您可以覆盖<一href="http://developer.android.com/reference/android/view/View.html#onTouchEvent%28android.view.MotionEvent%29"相对=nofollow> OnTouch 事件在CustomView /的CustomButton方法
You can override the OnTouch Event method in a CustomView / CustomButton
在里面你有MotionEvent是你可以检查是否触摸是你的三角形内(有一些数学的帮助:P)
Inside you have the MotionEvent were you can check if the Touch was inside your Triangle (with the help of some mathematics :P)
这篇关于有没有一种方法来创建Android上的三角按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!