1

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.

double-beep
  • 5,031
  • 17
  • 33
  • 41
piedra97
  • 37
  • 2

4 Answers4

1

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

Sana Ebadi
  • 6,656
  • 2
  • 44
  • 44
0

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);
Mark JW
  • 476
  • 3
  • 8
  • Ok, I just added what you told me and now is loading the drawable that is place in placeholder instead of the URL image. In my Logcat doesn't appear any error. – piedra97 Mar 26 '19 at 10:19
0

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

0

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.

piedra97
  • 37
  • 2