总结的Android中surfaceView清屏的方式。两种。(目的是为了自己方便回顾)仅供参考。

public static void qingP() {

  Canvas canvas = sh.lockCanvas(null);
  canvas.drawColor(Color.TRANSPARENT, Mode.CLEAR);
  Paint p = new Paint();
  canvas.drawBitmap(BackgroundImage, 0, 0, p);
  /*
   * 解锁画布并提交内容
   */
  sh.unlockCanvasAndPost(canvas);
 }

 

 


 public static void clearCanvas() {
  Paint p = new Paint();
  Canvas canvas = sh.lockCanvas(null);
  p.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
  canvas.drawPaint(p);
  p.setXfermode(new PorterDuffXfermode(Mode.SRC));
  canvas.drawBitmap(BackgroundImage, 0, 0, p);
  sh.unlockCanvasAndPost(canvas);
 }

你可能感兴趣的:(android开发,Android,clearCanvas)