YouKu地址 : http://v.youku.com/v_show/id_XMTczMzQwNTM5Ng==.html

Demo地址 : https://github.com/AndroidDevLog/AndroidDevLog/tree/master/21.ImageViewScaleType


 /**
     * Options for scaling the bounds of an image to the bounds of this view.
     */
    public enum ScaleType {
        /**
         * Scale using the image matrix when drawing. The image matrix can be set using
         * {@link ImageView#setImageMatrix(Matrix)}. From XML, use this syntax:
         * <code>android:scaleType="matrix"</code>.
         */
        MATRIX      (0),
        /**
         * Scale the image using {@link Matrix.ScaleToFit#FILL}.
         * From XML, use this syntax: <code>android:scaleType="fitXY"</code>.
         */
        FIT_XY      (1),
        /**
         * Scale the image using {@link Matrix.ScaleToFit#START}.
         * From XML, use this syntax: <code>android:scaleType="fitStart"</code>.
         */
        FIT_START   (2),
        /**
         * Scale the image using {@link Matrix.ScaleToFit#CENTER}.
         * From XML, use this syntax:
         * <code>android:scaleType="fitCenter"</code>.
         */
        FIT_CENTER  (3),
        /**
         * Scale the image using {@link 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.
         * From XML, use this syntax: <code>android:scaleType="center"</code>.
         */
        CENTER      (5),
        /**
         * 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),
        /**
         * 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;
    }

公共方法

static ImageView.ScaleType valueOf(String name)

final static ScaleType[] values()

枚举值

public static final ImageView.ScaleType CENTER

图片位于视图中间,但不执行缩放比例。在XML中,使用语法:android:scaleType=”center”

public static final ImageView.ScaleType CENTER_CROP

按比例统一缩放图片(保持图片的尺寸比例)便于图片的两维(宽度和高度)等于或大于相应的视图维度。然后图片居中于视图。在XML中,使用语法:android:scaleType=”centerCrop”

public static final ImageView.ScaleType CENTER_INSIDE

按比例统一缩放图片(保持图片的尺寸比例)便于图片的两维(宽度和高度)等于或小于相应的视图维度。然后图片居中于视图。在XML中,使用语法:android:scaleType=”centerInside”

public static final ImageView.ScaleType FIT_CENTER

缩放图片使用CENTER。在XML中,使用语法:android:scaleType=”fitCenter”

public static final ImageView.ScaleType FIT_END

缩放图片使用END。在XML中,使用语法:android:scaleType=”fitEnd”

public static final ImageView.ScaleType FIT_START

缩放图片使用START。在XML中,使用语法:android:scaleType=”fitStart”

public static final ImageView.ScaleType FIT_XY

缩放图片使用FILL. 。在XML中,使用语法:android:scaleType=”fitXY”

public static final ImageView.ScaleType MATRIX

当绘制时使用图片矩阵缩放。图片矩阵可以使用setImageMatrix(Matrix)进行设定。在XML中,使用语法:android:scaleType=”matrix”

公共方法

public static ImageView.ScaleType valueOf (String name)

参数

String name(名字)

返回值

ImageView.ScaleType

public static final ScaleType[] values ()

参数

NULL

返回值

ScaleType[]