Android的Canvas.drawPicture不工作与冰淇淋三明治设备 [英] Android Canvas.drawPicture not working in devices with ice cream sandwich

查看:564
本文介绍了Android的Canvas.drawPicture不工作与冰淇淋三明治设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要画一个图片画布

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);

然而<一href="http://developer.android.com/reference/android/view/View.html#setLayerType%28int,%20android.graphics.Paint%29">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);
    }
}

这篇关于Android的Canvas.drawPicture不工作与冰淇淋三明治设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆