3
有一些代碼在Android 2.2上完美運行,但在Android 4中只產生黑色視圖。這是onDraw方法:Android PorterDuffXfermode on 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:掩碼和聚光燈是兩個位圖。
不設置Xfermode畫兩個位圖繪製(不正確地爲我的範圍,但在正確的地方與正確的尺寸繪製)
非常感謝,它的工作! – Spotlight 2012-07-19 22:16:33