Reputation: 37
I'm doing a basic Android Studio Project for loading a URL into an ImageView using Picasso with Kotlin. I have followed every step from the official webpage of Picasso, but when I run my app the emulator shows an empty view.
In my Gradle I added the implementation of Picasso:
implementation 'com.squareup.picasso:picasso:2.71828'
And Internet permission within manifest tag too:
<uses-permission android:name="android.permission.INTERNET"/>
And in MainActivity
the basic use of Picasso:
Picasso.get().load("http://paproject.online/hp.jpg").into(imageTest)
imageTest
is the id of a Imageview
with layout_height = 200dp
and layout_weight = 200dp
.
Upvotes: 1
Views: 585
Reputation: 37
Ok, the problem is already solve. It seems that there is a problem loading images in Android 9.0. So the solution is in this link: Picasso image loading issue with Android 9.0 Pie. Thanks to everyone for your responses.
Upvotes: 0
Reputation: 7220
Maybe Your Photo size is too big so in ImageView
tag in XML
Edit layout_width
and layout_height
to Const Size Like 100dp.
and If U can Change Picasso with Glide. maybe Can help you
Upvotes: 1
Reputation: 66
You can resize your image before including it into imageView
Picasso
.with(context)
.load("http://paproject.online/hp.jpg")
.resize(200, 200) // resizes the image to these dimensions.
.into(imageViewResize);
Or you can use any cropping technique like .CenterCrop(). You can read more about this https://futurestud.io/tutorials/picasso-image-resizing-scaling-and-fit
Upvotes: 0
Reputation: 496
Your image is larger (1024x768) than your ImageView, but of course that should not be a reason for you to get blank. Try as below which also includes local image resource nopic for the error cases. Seems you have the correct include
// Lazy load the image with Picasso
get()
.load(yourURL)
.placeholder(R.drawable.nopic)
.error(R.drawable.nopic)
.into(img);
Upvotes: 0