如何缩小图像并适合ImageView,但避免向上缩放?
使用Glide解决,添加
...
.transform(new FitCenter(context) {
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
if (toTransform.getHeight() > outHeight || toTransform.getWidth() > outWidth)
return super.transform(pool, toTransform, outWidth, outHeight);
else
return toTransform;
}
})
...
目标android:scaleType="center"
中的和ImageView
。
似乎没有办法只使用ImageView
属性来获得这样的行为:(
答案 0 :(得分:0)
您可以将Picasso库与参数.onlyScaleDown()
Picasso
.with(context)
.load(imageURI)
.resize(600, 800) // or better use fit()
.onlyScaleDown() // the image will only be resized if it's bigger than 6000x2000 pixels.
.into(imageViewResizeScaleDown);
https://futurestud.io/tutorials/picasso-image-resizing-scaling-and-fit