9

I'm using a 128x128 circular image, animated by a drawable as a placeholder in Picasso.

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/loading_circle"
    android:pivotX="50%"
    android:pivotY="50%" />

And this is how my Java code implements it:

Picasso.with(context)
                        .load(message.getMediaUrl())
                        .config(Bitmap.Config.ARGB_4444)
                        .resize(w, h)
                        .onlyScaleDown()
                        .centerCrop()
                        .placeholder(R.drawable.progresscircle)
                        .into(messageImage);

Note that the image sizing parameters above are required by the final image that is loaded into my chat adapter's imageview.

The problem is, Picasso is blowing up and cropping the placeholder like this:

enter image description here

How can I set separate parameters for the placeholder to be suitably sized? Also, what exact parameters would be helpful?

Mayukh Nair
  • 623
  • 1
  • 6
  • 26

4 Answers4

6

in XML where you set ImageView add.

android:scaleType="centerCrop"

It may work. you can set fitXY instead of centerCrop if it is not working.

V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
4

As mentioned here,

  1. Inside your imageviews xml set android:scaleType="centerInside"

  2. Then add fit().centerCrop().noFade() like this

                     Picasso.with(context)
                    .load(message.getMediaUrl())
                    .config(Bitmap.Config.ARGB_4444)
                    .resize(w, h)
                    .onlyScaleDown()
                    .centerCrop()
                    .fit()
                    .noFade()
                    .placeholder(R.drawable.progresscircle)
                    .into(messageImage);
    
Navneet Krishna
  • 5,009
  • 5
  • 25
  • 44
0

Try this:

 Picasso
.with(context)
.load(message.getMediaUrl())
.fit()
// call .centerInside() or .centerCrop() to avoid a stretched image
.into(messageImage);
Dhruvi
  • 1,971
  • 2
  • 10
  • 18
0

change your Picasso call to this,

Picasso.with(context)
                    .load(message.getMediaUrl())
                    .config(Bitmap.Config.ARGB_4444)
                    .fit()
                    .centerCrop()
                    .placeholder(R.drawable.progresscircle)
                    .into(messageImage);
Jayanth
  • 5,954
  • 3
  • 21
  • 38