Picasso.with(UIUtils.getContext())
.load(serviceInShopPageListBean.getServiceDownUrl())
.transform(transformation)
.into(imageview)
Transformation transformation = new Transformation() {
@Override
public Bitmap transform(Bitmap source) {
int targetWidth = imageview.getWidth();
if (source.getWidth() == 0) {
return source;
}
double aspectRatio = (double) source.getHeight() / (double) source.getWidth();
int targetHeight = (int) (targetWidth * aspectRatio);
if (targetHeight != 0 && targetWidth != 0) {
Bitmap result = Bitmap.createScaledBitmap(source, targetWidth, targetHeight, false);
if (result != source) {
source.recycle();
}
return result;
} else {
return source;
}
}
@Override
public String key() {
return "transformation" + " desiredWidth";
}
};