首页 > 移动平台 > 详细

Android-清除Canvs内容的实现

时间:2014-06-24 18:00:08      阅读:580      评论:0      收藏:0      [点我收藏+]

SurfaceView背景透明:

setZOrderOnTop(true);
SurfaceHolder holder = this.getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT);

清除Canvas内容的实现方式一:

Canvas canvas = null;
try {
  synchronized (holder) {
    canvas = holder.lockCanvas(null);
    if (canvas == null) {
      return;
    }
    canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); 
  }
} catch (Exception e) {
  e.printStackTrace();
} finally {
  if (canvas != null) {
    holder.unlockCanvasAndPost(canvas);
  }
}

方式二:

 Paint paint = new Paint();  
 paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));  
 canvas.drawPaint(paint);  
 paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));  

 

Android-清除Canvs内容的实现,布布扣,bubuko.com

Android-清除Canvs内容的实现

原文:http://www.cnblogs.com/biyaxiong/p/3805645.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!