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

查看:29
本文介绍了如何使用 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天全站免登陆