How to scale bitmap to fit image view width and height
See original GitHub issueFirst of all millions of thanks,for this awesome and magnificent library. This is indeed a boon to Android Community. Right now I am using this library for my project where there are 1: GridView with 3 columns 2:GridView with 2 columns 3: ListView.
All these view,loads the same image from the server. First ,GridView with 3 columns is shown and then with 2 columns and finally a ListView. The loaded bitmap fits easily (i.e. takes entire image view width and height) on GridView,but on ListView the loaded bitmap only matches the height of ImageView not the width. The ImageView size on ListView is comparatively larger than that of GridView. So far following is my configuration
Picasso.with(context).load(item.imageUrls.get(0)).fit()
.into(holder.productImageView);
Picasso.with(context).load(item.postedProfileImage)
.placeholder(R.drawable.image_load_bg).fit()
.into(holder.userImageView);
And on Layout of ImageView
<ImageView
android:scaleType="fitXY"/>
Should I go for Custom Transformation or calculate ImageView width and height and then use resize property of Picasso. Or is there anything I have wrongly implemented.
Lastly,very very great work.
Issue Analytics
- State:
- Created 10 years ago
- Comments:9

Top Related StackOverflow Question
If you are using Picasso 2.0,
fit()will automatically wait for your view to be measured and essentially becomes a “delayed”resize(width, height)operation under the hood.Can you provide a screenshot of how it looks on the
ListView?Not a problem. Images probably look a bit better because of #220 change. The change has been merged but not yet released. It will be part of our next release, which is probably going to be version 2.0.1 as a minor update.
The sample app is also available here if you clone the repo. It’s in picasso-sample. You can change urls (thats what I did) and use it as a playground to test Picasso. It has a few samples of common cases that most devs need in their apps. Check it out.
I am closing this for now.