I want to implement eraser for my painting app . I am able to erase with the following code
paint.setColor(0x00000000);
paint.setAlpha(0x00);
But after erasing when you start painting again it does not paint properly so any idea to erase paint please suggest.
Try the below code.
paint.setAlpha(0xFF);//transperent color
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));//clear the draw
Also have a look at the sample FingerPaint.java in the api demos under the folder graphics.
setAlpha(int a)
Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged.
http://developer.android.com/reference/android/graphics/Paint.html. Have a look a the documentation.
Edit:
Also check this