Picasso not loading the image

老子叫甜甜 提交于 2019-12-01 02:41:55
Luboš Staráček

My guess is you should not call that fit() method in Picasso while your ImageView has its width and height defined by WRAP_CONTENT.

This method wait until the ImageView has been measured and resize the image to exactly match it's size. While your ImageView is having size defined by WRAP_CONTENT, then methods getMeasuredWidth() and getMeasuredHeight() seemingly returns 0 which is making your ImageView invisible.

Do not forget add permission to manifest

<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" /> 

If you are using networkPolicy(NetworkPolicy.OFFLINE) then it might possible that you will not get images using Picasso.

kds23

I was facing a similar issue where I had a ViewPager of images placed inside a fullscreen DialogFragment. The same ViewPager worked perfectly when placed elsewhere and Picasso loaded the images as expected. But only when placed in the fullscreen DialogFragment, some images would appear blank. It seemed that images were successfully fetched from server and loaded into the ImageView, but the ImageView was still appearing blank.

None of the above answers or similar threads worked for me.

So I switched to another great library called Glide. It is pretty much similar to Picasso. Find out more here and here. Even though this might not be the most relevant answer, it might be worth giving a shot for someone who has been stuck with a similar problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!