5

我对https://github.com/nostra13/Android-Universal-Image-Loader库有疑问。

我正在使用 imageLoader.displayImage(...) 将图像从我的数据库加载到列表视图中的 imageviews。

文档是这样说的:

ImageSize targetSize = new ImageSize(120, 80); // result Bitmap will be fit to this size
imageLoader.loadImage(imageUri, targetSize, displayOptions, new SimpleImageLoadingListener() {
    @Override
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        // Do whatever you want with Bitmap
    }
});

是否可以为 imageLoader.displayImage 方法声明目标大小?

4

3 回答 3

2

您可以使用 method:public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener)来设置ImageSize参数。

下载的图像将被解码并缩放为大小等于或大于传入 targetImageSize(通常稍大一点)的位图。

于 2015-03-11T07:51:52.247 回答
1

I would recommend you to use Picasso as an alternative to Universal-Image-Loader. Its really sleek and performance is really good.It provides good number of Apis.You can declare the target size by using following snippet.

Picasso.with(context)
  .load(url)
  .resize(50, 50)
  .centerCrop()
  .into(imageView)
于 2013-07-25T13:17:39.913 回答
0

我目前使用的是,我没有使用 ImageLoader 设置图像的尺寸,而是简单地设置包含它的布局的尺寸scaleType = centerCrop;

话虽如此,我仍然建议您改用 @Vipul 的答案那样改用毕加索。我遇到了不稳定性,在异步请求完成之前图像就被弄乱了。这从未发生在毕加索身上。

于 2020-11-30T04:15:10.947 回答