【发布时间】:2014-08-31 17:46:59
【问题描述】:
我正在使用 Nostra 的通用图像加载器来显示图像。这是我要显示的图片的网址:
http://hitbullseye.com/ATTACHMENT/test6eac134c-81ae-4a47-ba28-f25dcc48718a.jpg
我在 logcat 中收到以下错误:
我不明白的一件事是为什么 UIL 在 url 末尾附加 _480x800。我检查了图像,它的尺寸是 248x72。这是我的代码:
我在其中创建配置的应用程序类:
public class BullsEyeApplicationGlobal extends Application {
@Override
public void onCreate() {
super.onCreate();
File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext())
.taskExecutor(null)
.taskExecutorForCachedImages(null)
.threadPoolSize(3)
// default
.threadPriority(Thread.NORM_PRIORITY - 1)
// default
.tasksProcessingOrder(QueueProcessingType.FIFO)
// default
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
// default
.discCache(new UnlimitedDiscCache(cacheDir))
.imageDownloader(
new BaseImageDownloader(getApplicationContext())) // default
.imageDecoder(new BaseImageDecoder(false)) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) //
.writeDebugLogs().build();
ImageLoader.getInstance().init(config);
}
}
这里是我加载图片的地方:
ImageLoader imgL = ImageLoader.getInstance();
DisplayImageOptions options = new DisplayImageOptions.Builder()
.resetViewBeforeLoading(false) // default
.cacheInMemory(true) // default
.cacheOnDisc(true) // default
.considerExifParams(false) // default
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
.bitmapConfig(Bitmap.Config.ARGB_8888) // default
.build();
ImageView imgg = (ImageView) v1.findViewById(R.id.test_image);
imgL.displayImage(js.getString("TestImage"), imgg, options);
【问题讨论】:
-
UIL 不会在图像路径上附加任何内容。检查
js.getString("TestImage")添加附加文本的位置。 -
@intrepidkarthi 它的网址没有 _480x800,我已经检查过了。
-
日志的第一行是
http://hitbullseye.com/ATTACHMENT/_480x800。但是当图像出现时,图像名称被附加在两者之间。它正在您的代码中处理。只需在您的项目目录中进行字符串搜索_480x800。 -
@intrepidkarthi 我想这会消除你的疑虑 :) i.imgur.com/fUnoL9x.png
-
尝试运行
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)属性
标签: android universal-image-loader