如何在Android中具有弧形和矩形的imageview上确定触摸事件的坐标

时间:2016-05-23 07:34:47

标签: android android-imageview android-touch-event

我有以下形状图像

enter image description here

当我触摸蓝色区域或不在我的imageview中时,我想验证我的触摸事件。我需要将弧和矩形合并为一个并验证触摸事件的坐标?

如果它是一个圆圈,我会使用它

private boolean isIn3PointArea(float touchX, float touchY, float centerX, float centerY, double r){
    float x = touchX - centerX;
    float y = touchY - centerY;
    return (touchY < centerY && Math.sqrt(x*x+y*y) > r);
}

0 个答案:

没有答案