Android的通用图像装载机 - 我该如何正确设置规范? [英] Android Universal Image Loader - how do I set the specs correctly?
问题描述
我有一个应用程序,远程加载很多大的图像。 当我使用诺斯特拉的通用图像装载机( https://github.com/nostra13/Android-Universal - 图像 - 装载机)我经常收到内存不足的错误。我不知道我应该如何设置ImageLoader的,以prevent这一点。
I have an app that loads a lot of big images remotely. When I use nostra's Universal Image Loader (https://github.com/nostra13/Android-Universal-Image-Loader) I often get Out Of Memory errors. I don't know how I should set up the imageloader to prevent this.
这是我目前的ImageLoader的规格:
This is my current ImageLoader specs:
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.enableLogging()
.memoryCache(new WeakMemoryCache())
.build();
this.imgDispOpts = new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
.build();
this.imageLoader = ImageLoader.getInstance();
this.imageLoader.init(config);
是的,我打电话displayImage()时通过imgDispOpts。
And yes, I pass imgDispOpts when calling displayImage().
推荐答案
尽量在内存中不缓存,使用 EXACTLY
的规模型和 RGB_565
为位图解码。
Try not cache in memory, use EXACTLY
scale type and RGB_565
for bitmap decoding.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.enableLogging()
.build();
this.imgDispOpts = new DisplayImageOptions.Builder()
.cacheOnDisc()
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
这篇关于Android的通用图像装载机 - 我该如何正确设置规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!