【问题标题】:Converting a large Canvas in Bitmap in Android在 Android 中转换位图中的大画布
【发布时间】:2014-09-18 15:01:06
【问题描述】:

我的应用程序提供了一个自定义视图,它通过 onDraw() 方法在显示屏上绘制一些大形状。我的意图是将这个大画布转换为位图,但如果我使用 createBitmap() 方法,传递 canvas.getWidth()、canvas.getHeight() 参数,我会收到由创建位图 (OutOfMemory) 引起的运行时异常。

我该如何解决这个问题?有什么建议吗?

【问题讨论】:

    标签: android canvas bitmap


    【解决方案1】:

    尝试在清单文件中指定 android:largeHeap="true" 示例

    <application
        android:name=".MyApplication"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:screenOrientation="nosensor"
        android:largeHeap="true"
    

    【讨论】:

    • 不。异常仍然存在。还是谢谢你的回复
    猜你喜欢
    • 1970-01-01
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 2011-07-30
    • 1970-01-01
    相关资源
    最近更新 更多