Drawing with Transparent Paint on Android

The following Paint configuration should help:

mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(Color.TRANSPARENT);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));
mPaint.setAntiAlias(true);

I found that using

mPaint.setColor(Color.TRANSPARENT);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));

or

mPaint.setColor(Color.TRANSPARENT);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));

just made my paint black.

I had another approach which was to introduce a transparent color to my colors.xml

    <color name="transparentColor">#00ffffff</color>

I opted for the "00ffffff" case but i'm pretty sure that "00000000" will work also, depends on your case.

Final code looks like:

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(getResources().getColor(R.color.transparentColor));