Spo*_*ght 3 android paint android-4.0-ice-cream-sandwich
有一些代码在Android 2.2上完美运行,但在Android 4中只生成黑色视图.这是onDraw方法:
//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);
Run Code Online (Sandbox Code Playgroud)
PS:掩码和聚光灯是两个位图.
在没有设置Xfermode绘制的情况下,绘制了两个位图(对于我的范围不正确,但是在正确的位置绘制并且具有正确的大小)
您需要为该特定禁用硬件加速View.有关详细信息,请参阅硬件加速 - 不支持的绘图操作部分,以及有关如何有选择地禁用硬件加速的信息.例如:
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1405 次 |
| 最近记录: |