Glide not loading real image and stuck with placeholder

后端 未结 11 940
长情又很酷
长情又很酷 2021-02-02 05:59

I have a pretty basic load image from server line code:

Glide.with(view.getContext()).load(url).placeholder(R.drawable.default_profile).into(view);
11条回答
  •  不要未来只要你来
    2021-02-02 06:23

    Seems strange but only thing I could guess is Your URL is valid as You already said. Your remote is getting downloaded even getting applied on your image view but your placeholder is somehow hiding it. Glide has some bugs related to placeholder stuff.

    My suggestion would be to try below:

    Glide.with(view.getContext()).load(url).
    placeholder(R.drawable.default_profile).fitCenter().into(view);
    

    So the trick is placeholder is set via setImageDrawable() so the ImageView will just display it as usual, but you tell Glide to use the fitCenter explicitly which will fit the loaded image nicely within the ImageView's laid out size via a Transformation and then set it via setImageDrawable(). Since the fitted image is a perfect fit, center will just draw the image covering the whole area of the view.

    Give it a try.

提交回复
热议问题