从您发布的图片我假设你对你的ImageView
这样你就可以计算显示大小,像这样
boolean landscape = imageView.getWidth() > imageView.getHeight();
float displayedHeight;
float displayedWidth;
if (landscape){
displayedHeight = imageView.getHeight();
displayedWidth = (float) drawableWidth * imageView.getHeight()/drawableHeight;
} else {
displayedHeight = (float) drawableHeight * imageView.getWidth()/drawableWidth;
displayedWidth = imageView.getWidth();
}
注有FIT_CENTER的scaleType(或CENTER_INSIDE与绘制比ImageView的大):代码为了可读性而不简化。
可应用于所有scaleTypes另一种更鲁棒的方法是使用其的ImageView用于缩放图像
float[] f = new float[9];
imageView.getImageMatrix().getValues(f);
float displayedWidth = drawableWidth * f[Matrix.MSCALE_X];
float displayedHeight = drawableHeight * f[Matrix.MSCALE_Y];
矩阵