Canvas drawing using SurfaceView
suggest changeRemarks
A SurfaceView is a hole in the current window. Normal views can be placed on top of it.
- Draw from a dedicated thread, not the UI thread.
lockCanvas()can be called on the UI thread, but a long draw will freeze the interface. - The
CanvasfromlockCanvas()is not hardware-accelerated. - The surface uses two buffers: one on screen, one being drawn.
unlockCanvasAndPost()swaps them.
Call lockCanvas() and unlockCanvasAndPost() in pairs. Overlapping those calls, or unlocking a canvas you did not lock, deadlocks or throws.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents