How to get pixel color in Android?

后端 未结 3 1050
一向
一向 2021-01-23 18:26

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

3条回答
  •  别那么骄傲
    2021-01-23 19:30

    Try this

    Drawable drawable = button.getBackground();
    Bitmap bmp = ((BitmapDrawable) drawable).getBitmap();
    int color = bmp.getPixel(x_coordinate, y_coordinate);
    

提交回复
热议问题