I followed some other questions on the topic, and also API demos on XferModes, and attempted to create an ImageView that masks its content according to an alpha mask. The alpha bitmap contains 0 alpha for areas to be hidden and 255 alpha for areas to be shown.
This is the onDraw code:
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
Paint paint = new Paint();
paint.setFilterBitmap(false);
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
canvas.drawBitmap(mMaskBitmap, 0, 0, paint);
paint.setXfermode(null);
It doesn't work for me. If I put SRC_IN, the mask just gets drawn on top. If I put DST IN, I just see the original image.
Any advice?