通过ImageView的setScaleType()方法可设置图片在ImageView中的显示方式,具体可设置的类别有如下几种:
CENTER 居中显示图片,但图片不会被缩放;
CENTER_CROP 居中显示图片,对图片等比缩放(保持图片的长宽比),缩放后的图片长宽中较小的值能铺满ImageView控件;
CENTER_INSIDE 居中显示图片,对图片等比缩放(保持图片的长宽比),缩放后的图片长宽中较大的值能铺满ImageView控件;
FIT_CENTER 使用Matrix.ScaleToFit#CENTER的矩阵变换对图片进行缩放
FIT_END 使用Matrix.ScaleToFit#CENTER的矩阵变换对图片进行缩放、
FIT_START 使用Matrix.ScaleToFit#CENTER的矩阵变换对图片进行缩放
FIT_XY 使用Matrix.ScaleToFit#CENTER的矩阵变换对图片进行缩放
MATRIX 使用矩阵变化缩放图片
原文:
CENTER
Center the image in the view, but perform no scaling.
CENTER_CROP
Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
CENTER_INSIDE
Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
FIT_CENTER
Scale the image using Matrix.ScaleToFit#CENTER.
FIT_END
Scale the image using Matrix.ScaleToFit#END.
FIT_START
Scale the image using Matrix.ScaleToFit#START.
FIT_XY
Scale the image using Matrix.ScaleToFit#FILL.
MATRIX
Scale using the image matrix when drawing.