任何人都可以引導我如何在顯示在ImageView組件上的圖像上放置不同的圖層。 基本上我想在我的繪圖應用程序中實現撤消和重做功能。在Android中通過ImageView繪製圖層
目前我可以把文字或圖畫放在圖像上,但不能實現撤銷/重做功能。我想知道這可以通過維護一些分層的東西來實現。
Plz幫助我。
這是事先我當前的繪圖代碼..
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();
}
感謝...!
你能分享這個示例代碼嗎? – HourGlass
現在已經過時了,我會尋找代碼,如果發現,它會幫助你。 –
非常感謝... – HourGlass