简体   繁体   中英

Android Glide failing to load image

I am trying to load an image into an ImageView using the Glide library. The URL that I pass into the load() method points to an endpoint ('/api/user/5/logo'), which then returns the image. For some reason this doesn't seem to work.

However if I pass a URL that points directly to an image ('www.example.com/logo.png'), it works perfectly.

How do I get Glide to work perfectly with the required web service?

To recap, this works:

Glide.with(getContext())
        .load("www.example.com/content/logo.png")
        .centerCrop()
        .placeholder(R.drawable.mark)
        .into(imageView);

.. and this doesn't:

Glide.with(getContext())
        .load("www.example.com/api/user/5/logo")
        .centerCrop()
        .placeholder(R.drawable.mark)
        .into(imageView);

Any help would be greatly appreciated.

Try with this:

Glide.with(getContext())
 .load("http://www.example.com/api/user/5/logo").centerCrop().into(imageview)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM