问题描述
我试图删除图像的某些部分,所以我创建一个自定义的的ImageView
,因此擦除,我使用以下的油漆画
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));
我设置 XferMode
到 PorterDuff.Mode.CLEAR
来清除它适用于Android 4.1的优良形象,当我测试这个在Android 2.3它绘制一条黑线,而不是背景色,我也已经禁用了硬件加速,
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,
有人可以解释我为什么不上工作了Android 2.3
can someone explain me why this is not working on android 2.3
推荐答案
我有类似的问题,我用Canvas.cli preCT调用super.onDraw(画布)之前固定它。
I had similar issues and I fixed it by using Canvas.clipRect before calling super.onDraw(canvas).
这个问题帮了我:Clip在Android中使用从xfermode图像轮
This question helped me out: Clip round from image using xfermode in android
这篇关于涂料Xfermode借鉴了Android 2.2的黑线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!