问题
I'm trying to implement undo-redo functionality for erasing image in the custom view and have tried to implement the solution from ANDROID - Undo and Redo in canvas but when i click undo all it does is fill the coordinates and the circle with the same paint object that is underneath the bitmap and not the bitmap itself as the undo should function.Please help.
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
xn=context;
Log.e(TAG, "The Bitmap is " + bmrot);
mPaint = new Paint();
mPaint.setAlpha(0);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mPaint.setAntiAlias(true);
mPaint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.SOLID));
alphaPaint = new Paint();
alphaPaint.setAlpha(255);
pcanvas = new Canvas();
bitmap = bmrot.createBitmap(bmrot.getWidth(), bmrot.getHeight(), Bitmap.Config.ARGB_8888);
bac=bmrot;
setBackgroundColor(Color.parseColor("#4d4d4d"));
Log.e(TAG, "LOGGERHEAD2");
pcanvas.setBitmap(bitmap);
pcanvas.drawBitmap(bmrot, reqx, reqy, alphaPaint);
}
来源:https://stackoverflow.com/questions/36214443/android-undo-redo-in-customview