How to get pixel color in Android?

后端 未结 3 1051
一向
一向 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-23 19:10

    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

提交回复
热议问题