How to Change image color dynamically in android?

前端 未结 6 774
死守一世寂寞
死守一世寂寞 2020-12-13 12:58

I am doing such type of project ,In my project change Image color dynamically.

I have a one black shape color image ,when user click on this ima

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 13:35

    Put this in your OnDraw, just before you draw your square.

    if (userclicked){
    paint.setColor(Color.GREEN);
    } else {
    paint.setColor(Color.BLACK);
    }
    

    Of course that is if you are drawing it with canvas.drawRect(x0,y0,x1,y1,paint) which you would if you were drawing a simple shape like that.

提交回复
热议问题