Paint Xfermode draws black line on android 2.2

无人久伴 提交于 2020-01-16 00:46:15

问题


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

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