美文网首页
ImageView的ScaleType的区别

ImageView的ScaleType的区别

作者: Lost_Robot | 来源:发表于2017-09-27 10:55 被阅读78次

关于ImageView对图像缩放方式的控制,是通过ScaleType,它们分别表示不同的含义:

源码及说明:

 /**
     * 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;
    }

1.MATRIX:根据一个3x3的矩阵对其中图片进行缩放
2.FIT_XY:将图片非等比例缩放到大小与ImageView相同。
3.FIT_START: 缩放方式同FIT_CENTER,只是将图片显示在左方或上方,而不是居中。
4.FIT_CENTER:ImageView的默认状态,大图等比例缩小,使整幅图能够居中显示在ImageView中,小图等比例放大,同样要整体居中显示在ImageView中。
5.FIT_END:缩放方式同FIT_CENTER,只是将图片显示在右方或下方,而不是居中。
6.CENTER:图片大小为原始大小,如果图片大小大于ImageView控件,则截取图片中间部分,若小于,则直接将图片居中显示。
7.CENTER_CROP:将图片等比例缩放,让图像的短边与ImageView的边长度相同,即不能留有空白,缩放后截取中间部分进行显示。
8.CENTER_INSIDE:将图片大小大于ImageView的图片进行等比例缩小,直到整幅图能够居中显示在ImageView中,小于ImageView的图片不变,直接居中显示。

相关文章

  • ImageView中ScaleType centerInside

    ImageView中ScaleType centerInside与fitCenter区别 原文链接 在ImageV...

  • ImageView

    ImageView scaleType属性 ImageView的scaleType属性决定了图片在ImageVie...

  • ImageView的ScaleType的区别

    关于ImageView对图像缩放方式的控制,是通过ScaleType,它们分别表示不同的含义: 源码及说明: 1....

  • Android ImageView

    ImageView 的 scaleType参考1

  • scaleType / ScaleType

    整理旧笔记 ** android:scaleType / ImageView.ScaleType:**控制图片如何...

  • ImageView的缩放

    android中ImageView的ScaleType属性 ScaleType的值分别代表的意义: ImageVi...

  • ImageView的ScaleType原理及效果分析

    ImageView的ScaleType决定了图片在ImageView中的缩放形式。本文从ImageView的源码角...

  • ImageView的scaleType:

    matrix:表示原图从ImageView的左上角绘制,如果原图大于ImageView,那么多余的部分则裁剪掉,如...

  • ImageView 的scaleType

    之前一直对ImageView的多个Scaletype缩放类型的几个设置参数一知半解,看网上的各种解释也是当时明白事...

  • ImageVIew的scaleType

    总结的ImageView的"android:src"的八种scaleType的各种展示样式,每张图中包含两个Ima...

网友评论

      本文标题:ImageView的ScaleType的区别

      本文链接:https://www.haomeiwen.com/subject/bcnyextx.html