Android: Undo redo in CustomView

痴心易碎 提交于 2019-12-11 13:45:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!