Android Canvas drawing using SurfaceView

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

It's important to understand the basic concept of the surface view before using:

  • It's basically just a hole in the current window
  • Native UI can be placed on top of it
  • Drawing is done using a dedicated, non UI thread
  • Drawing is not hardware accelerated
  • Uses two buffers: One is currently shown, one is used for drawing.
  • unlockCanvasAndPost() swaps the buffers.

Deadlocks can easily occur if the lockCanvas() and unlockCanvasAndPost() methods are not called in the correct order.



Got any Android Question?