【问题标题】:Bitmap take too much time to load位图加载时间过长
【发布时间】:2016-12-20 06:55:51
【问题描述】:

我正在尝试在ImageView 中实现加载位图,但加载时间过长。我也用过ImageLoader,但它只支持url,不支持位图,那么如何立即显示位图?请帮忙解决!

使用图像加载器显示图像

对于网址,我使用了此代码

imgLoader.DisplayImage(mImage, R.mipmap.ic_launcher, imgProfile);

【问题讨论】:

  • 使用毕加索......
  • 但它不适用于位图!
  • 这可能对你有帮助,在 ImageView 中设置之前调整大小stackoverflow.com/questions/16874800/…
  • 谢谢!但它不起作用
  • 谁说ImageLoader只支持url,不支持bitmap?将SimpleImageLoadingListener 用于图像加载器,您将获得它的覆盖方法并获得位图对象。

标签: android bitmap imageview imageloader


【解决方案1】:

您可以使用任何ImageLoader library,例如GlidePicasso

这是使用Glide的sn-p

Glide.with(mContext)
                .load(your_image_url_or_resource_id)
                .asBitmap()
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        // you can do something with loaded bitmap here

                        yourImageViewRef.setImageBitmap(resource);
                    }
                });

如果你想使用 url 加载图片,试试这个代码

Glide.with(context).load(your_image_url_or_resource_id).placeholder(R.drawable.placeholder_icon)
                    .error(R.drawable.error_icon).into(yourImageViewRef);

【讨论】:

    猜你喜欢
    • 2016-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    • 2012-08-23
    • 2016-06-20
    • 2016-02-17
    相关资源
    最近更新 更多