清空繪圖板畫面在各網站已有解法, 像是
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
canvas.drawPaint(paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
// start your own drawing
或是這個網站也有解法 http://blog.csdn.net/yanzi1225627/article/details/8236309
然而,今天遇到奇怪現像, 造成清不乾淨, 這可能是我繪圖方法沒寫好, 只好多清空2次, 無言...
java code 如下(繪圖元件還是不熟)
for(int i = 0; i < 4; i++) {
clearDraw();
}
// 清除畫面
private void clearDraw() {
Canvas canvas = surHolder.lockCanvas();
canvas.drawColor(Color.TRANSPARENT);
//
Paint p = new Paint();
//清屏
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
canvas.drawPaint(p);
mCanvas.drawPaint(p);
surHolder.unlockCanvasAndPost(canvas);
}
沒有留言:
張貼留言