Picasso - How to Resize Placeholder

I use a 128x128 circular image animated by popped 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 so it implements my Java code:

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

Please note that the image settings mentioned above are required in the final image, which is uploaded to my chat image.

The problem is that Picasso explodes and cuts off the placeholder as follows:

enter image description here

How can I set separate parameters for a placeholder for a suitable size? Also, what exact parameters would be useful?

+5
source share
4 answers

in XML where you install ImageView add.

 android:scaleType="centerCrop" 

It might work. you can install fitXY instead of centerCrop if it doesn't work.

+4
source

Try the following:

  Picasso .with(context) .load(message.getMediaUrl()) .fit() // call .centerInside() or .centerCrop() to avoid a stretched image .into(messageImage); 
0
source

change your Picasso challenge to this,

 Picasso.with(context) .load(message.getMediaUrl()) .config(Bitmap.Config.ARGB_4444) .fit() .centerCrop() .placeholder(R.drawable.progresscircle) .into(messageImage); 
0
source

As mentioned here

  • Inside your set of imageview xml android:scaleType="centerInside"

  • 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); 
0
source

All Articles