Android Canvas Redo and Undo Operation

后端 未结 3 524
心在旅途
心在旅途 2020-12-04 16:03

I am working on a drawing project. My code is working perfectly other than canvas redo and undo operations. My undo operation removes paths from the paths Arr

3条回答
  •  萌比男神i
    2020-12-04 16:40

    Problem

    The path is only shown when you finish drawing it which leaves the user clueless as to what he is drawing

    Solution

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    
       for (Path p : paths){
            canvas.drawPath(p, mPaint);
        }
    
        //Draw path along with the finger
        canvas.drawPath(mPath, mPaint);
    }
    

    Add canvas.drawPath(mPath,mPaint) to onDraw() so the user gets a feeling of actually painting on the canvas.

提交回复
热议问题