我要画一个图片
在画布
按
mCanvas.drawpicture(mPicture, mRect)
使用目标API 7 <使用-SDK安卓的minSdkVersion =7/>
,它完全符合API&LT装置; 14,但与设备冰淇淋三明治,这是行不通的。显然,这是因为canvas.drawPicture不支持硬件加速:不支持的绘图操作
我试图通过禁用硬件加速的清单来解决这个问题:
Using target API 7 <uses-sdk android:minSdkVersion="7"/>
, it works perfectly in devices with API<14, but in devices with Ice Cream Sandwich, it doesn't work. Apparently this is because canvas.drawPicture is not supported with Hardware Acceleration: Unsupported Drawing Operations
I have tried to fix this by disabling the Hardware Acceleration in the Manifest:
<application android:hardwareAccelerated="false" ...>
但还是开不工作。
but still does't work.
我有同样的问题,并通过编程方式关闭硬件加速只认为将以此为图片解决
I had the same problem and solved by programmatically turning off hardware acceleration only on the view that will draw the Picture
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
然而setLayerType因为API仅支持11所以用这个方法来代替:
However setLayerType is only supported since API 11. So use this method instead:
public static void setHardwareAccelerated(View view, boolean enabled){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
if(enabled)
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
else view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}