Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load Image into ImageView from Url using Glide v4.0.0RC1

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.

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);

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

like image 978
sagar suri Avatar asked Jul 21 '17 08:07

sagar suri


2 Answers

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);
like image 177
Jeffrey Rajan Avatar answered Sep 24 '22 23:09

Jeffrey Rajan


Glide.with(this)
        .load("url here") // image url
        .placeholder(R.drawable.placeholder) // any placeholder to load at start
        .error(R.drawable.imagenotfound)  // any image in case of error
        .override(200, 200) // resizing
        .centerCrop()     
        .into(imageView);  // imageview object
like image 41
Bharath Avatar answered Sep 23 '22 23:09

Bharath