android中的PNG透明度和触摸
我有一个png,当我保存它时,它是一个正方形图像,但在正方形png内部是一个圆(有时是它的其他形状)。我如何检查用户何时处于png和图形内部,而不是用户处于png内部但透明度过高?是的,您可以这样做,您只需要手动检查触摸发生的像素的颜色android中的PNG透明度和触摸,android,Android,我有一个png,当我保存它时,它是一个正方形图像,但在正方形png内部是一个圆(有时是它的其他形状)。我如何检查用户何时处于png和图形内部,而不是用户处于png内部但透明度过高?是的,您可以这样做,您只需要手动检查触摸发生的像素的颜色 int color = Bitmap.getPixel(x,y); // x and y are the location of the touch event in Bitmap space int alpha = Color.getAlpha(color);
int color = Bitmap.getPixel(x,y); // x and y are the location of the touch event in Bitmap space
int alpha = Color.getAlpha(color);
boolean isTransparent = (alpha==0);
注意:根据您实现触摸监听器的方式,可能需要将触摸事件的x,y位置转换为图像视图的x,y坐标