问题
I am trying to erase some part of Image, so I am Creating a custom ImageView
, so for erasing, I am using following paint to draw
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(Color.TRANSPARENT);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(30);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
I am setting XferMode
to PorterDuff.Mode.CLEAR
to clear the Image which works fine on android 4.1 but when I am testing this on android 2.3 it draws a black line instead of background color, and I also have disabled the Hardware Acceleration,
can someone explain me why this is not working on android 2.3
回答1:
I had similar issues and I fixed it by using Canvas.clipRect before calling super.onDraw(canvas).
This question helped me out: Clip round from image using xfermode in android
来源:https://stackoverflow.com/questions/15200187/paint-xfermode-draws-black-line-on-android-2-2