官方文档如下解释:
ImageView.ScaleType | CENTER | Center the image in the view, but perform no scaling. |
ImageView.ScaleType | 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). |
ImageView.ScaleType | 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). |
ImageView.ScaleType | FIT_CENTER | Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. The result is centered inside dst. |
ImageView.ScaleType | FIT_END | Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. END aligns the result to the right and bottom edges of dst. |
ImageView.ScaleType | FIT_START | Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. START aligns the result to the left and top edges of dst. |
ImageView.ScaleType | FIT_XY | Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src. |
ImageView.ScaleType | MATRIX | Scale using the image matrix when drawing. |
下图是图片效果,横向是scaleType的各种属性(与上表从上到下,意义对应。),纵向分别对应的是大图(图片比View大),中图(图片的宽度比View大,高度比View小),小图 (图片比View小)
结合图片效果,来看各个属性的意义:
ImageView.ScaleType | CENTER | 不进行缩放,居中显示图片。如果图片超出ImageView,则截掉超出的部分。 | ||||
ImageView.ScaleType | CENTER_CROP | 等比缩放图片,直到图片的宽度和高度都达到或超过ImageView的宽度和高度。(padding值是负数) | ||||
ImageView.ScaleType | CENTER_INSIDE | 如果图片的宽度或高度超过ImageView的宽度或高度,则缩放图片,直到图片的宽度和高度都小于或等于ImageView的宽度和高度。如果图片的宽高都小于ImageView的宽高,则居中显示图片 | ||||
ImageView.ScaleType | FIT_CENTER | 等比缩放图片,直到图片的宽度和高度都小于或等于ImageView的宽度和高度。但是至少要宽度或高度与ImageView的宽度活高度对齐。图片居中显示 | ||||
ImageView.ScaleType | FIT_END | 缩放效果和FIT_CENTER一样,只是图片显示的位置不同。图片显示在右下部 | ||||
ImageView.ScaleType | FIT_START | 缩放效果和FIT_CENTER一样,只是图片显示的位置不同。图片显示在左上部 | ||||
ImageView.ScaleType | FIT_XY | 不保持图片的原始比例,缩放图片直到宽高和ImageView的宽高一样。 | ||||
ImageView.ScaleType | MATRIX | Scale using the image matrix when drawing. (以后研究) |