I make an Application in which I want to erase drawing lines with event. For this I used
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
but at the time of erasing a line, that line becomes black first then erased. I want a transparent color for erasing a drawing a path.
What you need to do is set the color between drawing. paint. setColor(color. RED); // Will apply to first path.
The Paint class holds the style and color information about how to draw geometries, text and bitmaps.
ANTI_ALIAS_FLAG. Paint flag that enables antialiasing when drawing.
I have gone through the FingerPaint.java
from APIDemos i.e android-sdk\samples\android-17\ApiDemos
and modified
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFAAAAAA);
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
canvas.drawPath(mPath, mPaint);
}
to
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFAAAAAA);
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
mCanvas.drawPath(mPath, mPaint); // this line changed
// mCanvas is Canvas variable which is
// initialized in onSizeChanged()
}
Now it is not drawing a black color while erasing, everything works fine. Not sure it is 100% proper answer but it works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With