解析#ImageView之ScaleType属性#

ScaleType.CENTER

Center the image in the view, but perform no scaling. From XML, use this syntax: android:scaleType="center".

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). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerCrop".

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). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerInside".

ScaleType.FIT_CENTER

Scale the image using Matrix.ScaleToFit.CENTER. From XML, use this syntax: android:scaleType="fitCenter".

android.graphics.Matrix.ScaleToFit.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.

ScaleType.FIT_END

Scale the image using Matrix.ScaleToFit.END. From XML, use this syntax: android:scaleType="fitEnd".

Open Declarationandroid.graphics.Matrix.ScaleToFit.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.

ScaleType.FIT_START

Scale the image using Matrix.ScaleToFit.START. From XML, use this syntax: android:scaleType="fitStart".Open Declaration

android.graphics.Matrix.ScaleToFit.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.

ScaleType.FIT_XY

Scale the image using Matrix.ScaleToFit.FILL. From XML, use this syntax: android:scaleType="fitXY".

Open Declarationandroid.graphics.Matrix.ScaleToFit.FILL

Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

ScaleType.MATRIX

Scale using the image matrix when drawing. The image matrix can be set using ImageView.setImageMatrix(Matrix). From XML, use this syntax: android:scaleType="matrix".

aspect ratio 长宽比、纵横比


你可能感兴趣的:(imageview,ScaleType,ScaleType属性)