Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的PNG透明度和触摸_Android - Fatal编程技术网

android中的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);

我有一个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);
boolean isTransparent = (alpha==0);
注意:根据您实现触摸监听器的方式,可能需要将触摸事件的x,y位置转换为图像视图的x,y坐标