public void < span class="hljs-title">ClearDraw(){ Canvas canvas = null; try{ canvas = surfaceHolder.lockCanvas(null); canvas.drawColor(Color.WHITE); canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.SRC);} catch(Exception e){ }finally{ if span>(canvas != null){ surfaceHolder.unlockCanvasAndPost(canvas);}} }
Call this method before drawing to clear the canvas .
public void< /span> ClearDraw(){ Canvas canvas = null; try{ canvas = surfaceHolder.lockCanvas(null); canvas.drawColor(Color.WHITE); canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode. SRC); }catch(Exception e){ }finally{ if(canvas != null){ surfaceHolder.unlockCanvasAndPost(canvas);}} }
Call this method before drawing You can clear the canvas.