jagrakye jagrakye - 2 months ago 6x
Android Question

Android: Is there a way to draw on top of an existing canvas using a secondary canvas?

Basically I'm trying to make a change to an already drawn canvas. There is a portion of it that will change based on user input. Redrawing the entire canvas takes too much time, so I was thinking of making a separate canvas using the same view and holder, and just drawing the item that changes on top of the canvas. The bitmap I'm drawing over it appears to completely wipe out the previous canvas once drawn. Any way around this?

To ask a simpler question, I need to be able to draw on top of an existing view(surfaceview in this case) without erasing it.


That doesn't make much sense since the Canvas instance is a single one that is propagated top-down through the view hierarchy. If you want to refresh just a piece of your custom view, you can use methods such as view.invalidate(Rect) or view.invalidate(left, top, right, bottom).