畫新的東西之前需要先清除畫布內容:
方法1:
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
方法2
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
canvas.drawPaint(paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));