如何擦除画布previous图纸? [英] How to erase previous drawing on Canvas?

查看:178
本文介绍了如何擦除画布previous图纸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个背景图像(图)上,我需要定期绘制你 - 是 - 这里的图标。我用画布绘制在地图上方的图标。假设绘制过程中被触发按钮点击(见下文code),我怎么能抹去previous图纸?

 私人无效displayUserPos(点userPos){
    位图标记= BitmapFactory.de codeResource(getResources(),R.drawable.ic_yah);
    canvas.drawBitmap(标记,(浮动)userPos.getX(),(浮动)userPos.getY(),NULL);
    imgView.setImageBitmap(fmOverlay);
}
 

解决方案

  canvas.drawColor(0,Mode.CLEAR);
 

更多信息<一个href="http://developer.android.com/guide/topics/graphics/index.html">http://developer.android.com/guide/topics/graphics/index.html

I have a background image (a map) on which I need to regularly draw the you-are-here icon. I use Canvas to draw the icon on top of the map. Assuming that the drawing process is triggered on button click (see code below), how can I erase the previous drawing?

private void displayUserPos(Point userPos) {
    Bitmap marker = BitmapFactory.decodeResource(getResources(), R.drawable.ic_yah);
    canvas.drawBitmap(marker, (float)userPos.getX(), (float)userPos.getY(), null);
    imgView.setImageBitmap(fmOverlay);
}

解决方案

canvas.drawColor(0, Mode.CLEAR);

More info http://developer.android.com/guide/topics/graphics/index.html

这篇关于如何擦除画布previous图纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆