Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Picasso - how to resize placeholder

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?

like image 829
Mayukh Nair Avatar asked Jul 01 '16 06:07

Mayukh Nair


People also ask

What is placeholder in Picasso?

You can use a placeholder image by using the *.placeholder(R.drawable.image_name)* in your Picasso call like: Picasso.with(context) .load(imageUrl) .placeholder(R.drawable.image_name) If you want to use a progress bar instead of a placeholder image you can create a callback inside the .into function.

How do you resize a picture on Picasso?

Image Resizing with resize(x, y) This will resize the image before displaying it in the ImageView .

How do you load an image into an ImageView from an image URL using Picasso?

Image loading using Picasso is very easy, you can do it like this way Picasso. get(). load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.


1 Answers

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.

like image 84
Anurag Shrivastava Avatar answered Sep 30 '22 11:09

Anurag Shrivastava