Il existe un code qui fonctionne parfaitement sur Android 2.2, mais dans Android 4 ne produit qu'une vue en noir. C'est la méthode onDraw:Android PorterDuffXfermode sur ICS
//Object initialization
Paint paint=new Paint();
PorterDuffXfermode exclude=new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT);
paint.setAntiAlias(true);
paint.setDither(true);
//The dimensions are OK and they are at the center of the screen
canvas.drawBitmap(mask, screenWidth/2 - pixelsToSp(100), screenHeight/2 - pixelsToSp(100), paint);
paint.setXfermode(exclude);
//PS:targetRect is a portion of screen
canvas.drawBitmap(source, null, targetRect, p);
paint.setXfermode(null);
PS: masque et projecteur sont deux bitmap.
Sans réglage Xfermode peindre les deux bitmap sont tirées (à tort pour ma portée, mais tiré au bon endroit et à la bonne taille)
Merci beaucoup, cela a fonctionné! – Spotlight