Skip to content

Instantly share code, notes, and snippets.

@Royalone94
Forked from comoc/ClearCanvas.java
Created December 14, 2018 03:38
Show Gist options
  • Save Royalone94/a78631597a13d64977adb42ea9508f51 to your computer and use it in GitHub Desktop.
Save Royalone94/a78631597a13d64977adb42ea9508f51 to your computer and use it in GitHub Desktop.
Clear the Canvas of a SurfaceView for Android.
// Obtain a SurfaceView.
// SurfaceView surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
Canvas canvas = surfaceView.getHolder().lockCanvas();
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// Draw someting
surfaceView.getHolder().unlockCanvasAndPost(canvas);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment