I want to draw a rectangle on button click event horizontally aligned to the previous one. But the problem is: every time button is clicked then in ondraw() method a new canvas is drawn that hides the previously drawn rectangle.Can anyone tell me how to solve this problem. I have applied many solutions but dont work. please help me
Share
You need to back the canvas with something to keep what you draw, otherwise you need to keep track of prior draw information and redraw.
Usually, canvas is backed by a “drawing” bitmap to keep what was drawn. See this for more details what is the relation between Canvas and Bitmap?