Reputation: 653
I'm using a 128x128 circular image, animated by a drawable as a placeholder in Picasso.
<?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:
How can I set separate parameters for the placeholder to be suitably sized? Also, what exact parameters would be helpful?
Upvotes: 9
Views: 7106
Reputation: 5017
As mentioned here,
Inside your imageview
s xml set 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);
Upvotes: 3
Reputation: 692
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.
Upvotes: 6
Reputation: 6307
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);
Upvotes: 0
Reputation: 1981
Try this:
Picasso
.with(context)
.load(message.getMediaUrl())
.fit()
// call .centerInside() or .centerCrop() to avoid a stretched image
.into(messageImage);
Upvotes: 0