ImageView 的 ScaleType


  /**
     * Options for scaling the bounds of an image to the bounds of this view.   将一个图片的边界缩放到这个view边界的几种选项
     */
    public enum ScaleType {
        /**
         * Scale using the image matrix when drawing. The image matrix can be set using 用指定的Matrix缩放
         * {@link ImageView#setImageMatrix(Matrix)}. From XML, use this syntax:
         * <code>android:scaleType="matrix"</code>.
         */
        MATRIX      (0),  
        /**
         * Scale the image using {@link Matrix.ScaleToFit#FILL}.         按照Matrix.ScaleToFit#FILL来缩放(填满)
         * From XML, use this syntax: <code>android:scaleType="fitXY"</code>.
         */
        FIT_XY      (1),
        /**
         * Scale the image using {@link Matrix.ScaleToFit#START}.        按照Matrix.ScaleToFit#Start来缩放(开始处对齐)
         * From XML, use this syntax: <code>android:scaleType="fitStart"</code>.
         */
        FIT_START   (2),
        /**
         * Scale the image using {@link Matrix.ScaleToFit#CENTER}.        按照Matrix.ScaleToFit#Center来缩放(中央对齐)
         * From XML, use this syntax:
         * <code>android:scaleType="fitCenter"</code>.
         */
        FIT_CENTER  (3),
        /**
         * Scale the image using {@link Matrix.ScaleToFit#END}.          按照Matrix.ScaleToFit#END来缩放(末尾对齐)
         * From XML, use this syntax: <code>android:scaleType="fitEnd"</code>.
         */
        FIT_END     (4),
        /**
         * Center the image in the view, but perform no scaling.          放在view的正中央,不缩放
         * From XML, use this syntax: <code>android:scaleType="center"</code>.
         */
        CENTER      (5),
        /** 均匀缩放图片(维持图片的宽高比)。让图片的宽和高都 >= view的宽和高(负padding)。图片之后被放在view的中央。CENTER_CROP就是放在中央,看起来图片缩放之后多余的被view裁掉了
         * 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: <code>android:scaleType="centerCrop"</code>.
         */
        CENTER_CROP (6),
        /** 均匀缩放图片(维持图片的宽高比)。让图片的宽和高都 <= view的宽和高(负padding)。图片之后被放在view的中央。CENTER_INSIDE就是放在中央,图片缩放后不许超过view的边界
         * 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: <code>android:scaleType="centerInside"</code>.
         */
        CENTER_INSIDE (7);
        
        ScaleType(int ni) {
            nativeInt = ni;
        }
        final int nativeInt;
    }
原文地址:https://www.cnblogs.com/maxiaodoubao/p/4680397.html