3 回答

TA贡献1804条经验 获得超7个赞
maxWidth
android:scaleType="centerInside" android:adjustViewBounds="true"

TA贡献1712条经验 获得超3个赞
下面的代码使位图完全符合相同大小的图像视图。获取位图图像的高度和宽度,然后借助图像视图的参数计算新的高度和宽度。这给了你所需要的图像与最佳的纵横比。
int currentBitmapWidth = bitMap.getWidth();
int currentBitmapHeight = bitMap.getHeight();
int ivWidth = imageView.getWidth();
int ivHeight = imageView.getHeight();
int newWidth = ivWidth;
newHeight = (int) Math.floor((double) currentBitmapHeight *( (double) new_width / (double) currentBitmapWidth));
Bitmap newbitMap = Bitmap.createScaledBitmap(bitMap, newWidth, newHeight, true);
imageView.setImageBitmap(newbitMap)
好好享受吧。
- 3 回答
- 0 关注
- 408 浏览
添加回答
举报