如何使用Glide v4.0.0RC1从Url​​将图像加载到ImageView中 [英] How to load Image into ImageView from Url using Glide v4.0.0RC1

查看:125
本文介绍了如何使用Glide v4.0.0RC1从Url​​将图像加载到ImageView中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在应用程序中将Glide库从v3更新到了v4. 但是现在我无法从URL加载图像.以前,它在v3上运行良好.

I just updated Glide library from v3 to v4 in my application. But Now I am not able to load image from the url. Previously it was working fine with v3.

这是我的Glide代码:

Here is my Glide code:

Glide.with(context).load(galleryList.get(itemPosition).getImage()).thumbnail(Glide.with(context).load(R.drawable.balls)).apply(options).into(holder.kolamImage);

v4的变化是什么?我浏览了文档,但仍然没有帮助.

What is the change in v4? I went through the document but still no help.

推荐答案

如果您使用的是 Glide v4.0.0-RC1 ,则需要使用RequestOptions添加占位符,错误图片和其他选择.这是一个有效的例子

If you are using Glide v4.0.0-RC1 then you need to use RequestOptions to add the placeholder, error image and other option. Here is an working example

RequestOptions options = new RequestOptions()
                    .centerCrop()
                    .placeholder(R.mipmap.ic_launcher_round)
                    .error(R.mipmap.ic_launcher_round);



 Glide.with(this).load(image_url).apply(options).into(imageView);

这篇关于如何使用Glide v4.0.0RC1从Url​​将图像加载到ImageView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆