I have set a PNG image(image having transparent background) as button background, When I touch the button it shows me X-coordinate and Y-coordinate of the button’s touched posit
Try this
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.picture);
int color=bitmap.getPixel(x_coordinate, y_coordinate);
Use this color in your if statements to do the required operations
First, you can get the Bitmap with the BitmapFactory like this:
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic1);
Now you have the Bitmap. On this Bitmap, you can call the function getPixel(int x, int y)
to get the Color of this Pixel.
I guess you then can get the alpha from that Color..
See the following links for further information:
Try this
Drawable drawable = button.getBackground();
Bitmap bmp = ((BitmapDrawable) drawable).getBitmap();
int color = bmp.getPixel(x_coordinate, y_coordinate);