There is a custom View, in the OnDraw method of which I perform some drawing operations. I need to realize that after some operations, the contents of Canvans were preserved and remained on the background, and the subsequent changes in OnDraw were drawn from above. How to implement it?

  • for example, you can use two I twist one on top of the other with alpha, if one can be realized with two layers or you can make a screenshot of what you draw and set it as background - georgehardcore
  • you can draw canvas contents on Bitmap, and use this Bitmap - Vladyslav Matviienko
  • The problem is that I need to perform this operation many times. And how is this implemented in painter? - antonin14d
  • And how is this an option. Create an array in which to add an object with coordinates and in OnDraw in a loop to draw them. - antonin14d

1 answer 1

You can use the flag in the onDraw method, in the absence of which the outline will not be redrawn. For example, private boolean _firstDraw;

private void doDraw(Canvas a_canvas){ if (_firstDraw) { _firstDraw = false; _canvas.drawBitmap(_backgroundImage, 0, 0, null); //example ... //Set other drawing properties } ... //do other drawing } 

Hope this helps you. Good luck!