Android change canvas background color without losing any drawings from it

后端 未结 4 1575
野性不改
野性不改 2021-02-09 02:06

I\'m trying to find a way to set background of canvas with a color picked up from custom color picker without removing any drawings on it. I\'m trying to create an application w

4条回答
  •  执笔经年
    2021-02-09 02:28

    Look if you want to change in canvas then you have to call invalidate to apply these changes your screen.And if you call invalidate then your onDraw() method will call.

    If you want to change just background color of canvas from color picker then save color value in variable and call invalidate just after saving variable.Now your onDraw() will call.Now change background of canvas by calling setBackgroundColor(color variable) in onDraw() and draw everything else you want

提交回复
热议问题