【发布时间】:2011-11-12 20:08:33
【问题描述】:
谁能指导我如何在 ImageView 组件上显示的图像上放置不同的绘图层。 基本上我想在我的绘图应用程序中实现撤消和重做功能。
目前我可以在图像上放置文本或绘图,但无法实现撤消/重做功能。我想知道这可以通过维护一些分层的东西来实现。
请帮帮我。
这是我当前的绘图代码..
try {
image.buildDrawingCache();
Bitmap bitmap = image.getDrawingCache();
try
{
bitmap = getResizedBitmap(bitmap, image.getHeight(),
image.getWidth());
} catch (OutOfMemoryError e) {
Toast.makeText(getApplicationContext(), e.getMessage(), 1)
.show();
}
TextPaint tp = new TextPaint();
tp.setColor(Color.GREEN);
tp.setAntiAlias(true);
tp.setTextSize(30);
Canvas canvas = new Canvas(bitmap);
canvas.drawText(input.getText().toString(), xPos, yPos, tp);
image.setImageBitmap(bitmap);
input.setText("");
input.setVisibility(View.INVISIBLE);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), e.getMessage(), 1).show();
}
提前谢谢...!!!
【问题讨论】:
标签: android drawing layer undo redo