ArrayList
ArrayList<Pair<Path, Float>> foregroundPaths = new ArrayList<Pair<Path, Float>>();
Paint initilization
mPaint = new Paint();
mPaint.setAntiAlias(false);
mPaint.setDither(true);
mPaint.setColor(0x0FFF0000);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.BEVEL);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(Math.abs(ImageViewTouch.brushSize
/ getScale()));
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
mPaint.setAlpha(0x80);
OnDraw
canvas.save();
displayRectF = new RectF();
canvas.concat(getDisplayMatrix());
rect = canvas.getClipBounds();
displayRectF.set(rect);
for (Pair<Path, Float> p : foregroundPaths) {
mPaint.setStrokeWidth(p.second);
canvas.drawPath(p.first, mPaint);
}
canvas.restore();
Above codes are capable of drawing on canvas using finger. But the problem is when multiple path crossing each other its overlap. I have attached a link of my app snapshot. Overlapping is inside the green rectangle. I set Xfermode to paint but not working as i expect.
Please help me and suggest me, what should i do to remove this problem. any suggestion will be appreciated. Thanks