1

I am creating a custom paint view, in that we can paint and erase. The paint part is done successfully. But when is move to erase the colour, I got some issue.

  private Paint getPaint() {
        if (mMode == Mode.MARKER) {
            mPaint.setXfermode(null);
            mPaint.setStrokeWidth(mStrokeWidth);
        } else {
            mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
            mPaint.setStrokeWidth(mStrokeWidthForEraser);
        }
        return mPaint;
    }

The problem was when I clear the point the whole bitmap goes to black. So I searched for that And I found suitable answer setLayerType.

setLayerType(LAYER_TYPE_HARDWARE, null);

This was fixed the color changing issue. But my line got distorted and if I draw somewhere the line draws in other places also.

So what is this issue?

Thanks in advance

noobEinstien
  • 3,147
  • 4
  • 24
  • 42

0 Answers0