Reputation: 1624
Can I use two or more canvases to draw in SurfaceView ?
For example
Canvas canvas1 = holder.lockCanvas;
canvas1.drawPath(path1, paint1);
holder.unlockCanvasAndPost(canvas1);
Canvas canvas2 = holder.lockCanvas;
canvas2.drawPath(path2, paint2);
holder.unlockCanvasAndPost(canvas2);
This code shows incorrect picture.
Upvotes: 0
Views: 784
Reputation: 52353
An Android Canvas is just a way to issue drawing commands. The SurfaceHolder hands you a Canvas that is only valid between the lock()
and unlockCanvasAndPost()
calls.
You're getting a different Canvas each time you lock the SurfaceHolder. SurfaceView is double- or triple-buffered, so you'll be rotating through a series of buffers as well.
Make sure you're not confusing the Android definition of "Canvas" with its use in other contexts.
Upvotes: 1