Android - 如何在 Imageview 中加载大于 20mb 的图像
Android - How to Load More then 20mb Image in Imageview
我的项目是关于 Android 中的图像处理。我的问题是,当我在 ImageView 中加载一个 22MB 的图像时,出现了 OutOfMemoryError。
错误:
java.lang.OutOfMemoryError: Failed to allocate a 244588824 byte
allocation with 11397108 free bytes and 79MB until OOM at
dalvik.system.VMRuntime.newNonMovableArray(Native Method)
您需要调整图像大小并将子样本加载到图像视图:http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
您可以使用一些库作为 Picaso,Glide 来做到这一点。
将此添加到您的清单文件中:
<application
...
android:largeHeap="true"
...
>
</application>
我的项目是关于 Android 中的图像处理。我的问题是,当我在 ImageView 中加载一个 22MB 的图像时,出现了 OutOfMemoryError。
错误:
java.lang.OutOfMemoryError: Failed to allocate a 244588824 byte allocation with 11397108 free bytes and 79MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
您需要调整图像大小并将子样本加载到图像视图:http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
您可以使用一些库作为 Picaso,Glide 来做到这一点。
将此添加到您的清单文件中:
<application
...
android:largeHeap="true"
...
>
</application>