Picasso center image without resizing in ImageView

I ran into this simple problem with Picasso library

. I haven't found a way to center the image ImageView

like it does android:ScaleType="center"

without cropping. Do you have any ideas on how to solve this? My problem is that I don't know at runtime the height and width of the download BitMap

, so I can't use it correctly resize()

.

+3


source to share


3 answers


This is a bit late, but for those looking for a solution:



Picasso
    .with(context)
    .load(ImageURL)
    .fit()
    // call .centerInside() or .centerCrop() to avoid a stretched image
    .into(imageViewFit);

      

+2


source


If your ImageView

fixed and flexible one dimension, another measure (eg, android:width="match_parent"

, android:height="wrap_content"

), you can use android:adjustViewBounds="true"

to change the size ImageView

to display the image without cropping.



+1


source


I do not consider it necessary to center without resizing,

 Picasso.get()
                        .load(source).resize(1650,700)
                        .centerCrop(Gravity.CENTER).into(imageView, new Callback() 

      

0


source







All Articles