I have a custom view class which extends the view. I am using the over-ridden onDraw method to doodle on the canvas. I have a list of a POJO which includes Path and Paint with the help of which I can re-create the old paths drawn, something like this:
@Override
protected void onDraw(Canvas canvas){
for (POJO pojo : pojoList {
canvas.drawPath(pojo.path, pojo.paint);
}
canvas.drawPath(path, paint);
}
I want to implement erase function which should work like a proper erase. I know one way to do it to write to a bitmap and use setXfermode to CLEAR which properly works. But pixelation doesn't look good on smaller resolution devices. I don't want to use WHITE color paint as underneath this view I have an ImageView, so coloring it white will also effect the ImageView as well. Any idea or snippet towards solving this problem is highly appreciated.
This works just fine. If someone finds a better solution. Kindly update