Android : Resize image with Picasso library

on Friday, October 24, 2014


I am using Picasso to show image from url. My question is how can I resize the image to a variable heigth and width without crop the image? Currently when I resize the image without centerCrop() it stretches the image. This is what I have:



// Get current display dimensions
DisplayMetrics metrics = getResources().getDisplayMetrics();
width = metrics.widthPixels;
height = metrics.heightPixels / 2;

// Set image from URL in ImageView
Picasso.with(getApplicationContext())
.load(path)
.placeholder(R.drawable.loading).resize(width, height)
.centerCrop().into(image);

0 comments:

Post a Comment