首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ImageView缩放选项

ImageView缩放选项

作者头像
用户1172465
发布2018-01-08 14:06:41
1.5K0
发布2018-01-08 14:06:41
举报
文章被收录于专栏:everhadeverhad

ImageView.ScaleType

将图片边界缩放到所在view边界时的缩放选项。 Options for scaling the bounds of an image to the bounds of this view.

不同选项含义

CENTER

居中,不缩放。

Center the image in the view, but perform no scaling.

CENTER_CROP

居中,如果图片宽或高比view小,就等比放大使得宽和高都大于等于view,计算时view大小减去对应padding值。 比如view是100x100,图片是120x50,view的padding为10,那么就放大至(100 - 2*10) / 50 = 1.6倍。 图片宽高都大于等于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).

CENTER_INSIDE

居中,如果图片宽或高比view大,就等比缩小使得宽或高都小于等于view,计算时view大小减去对应padding值。 比如view是100x100,图片是120x50,view的padding为10,那么就缩小至(100 - 2*10) / 120 = 2/3倍。 图片宽高都小于等于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).

FIT_CENTER

居中,填充,等比缩放使得宽高都小于等于view,其中宽或高至少一个和view相等。 和CENTER_INSIDE的不同是总是保证至少宽或高中一个和view相等。

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 entered inside dst.

FIT_END

右下对齐,填充,等比缩放使得宽高都小于等于view,其中宽或高至少一个和view相等。

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.

FIT_START

左上对齐,填充,等比缩放使得宽高都小于等于view,其中宽或高至少一个和view相等。

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.

FIT_XY

非等比缩放,让图片宽高和view一致。

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

MATRIX

使用指定的matrix对象缩放。

Scale using the image matrix when drawing. The image matrix can be set using setImageMatrix(Matrix).

上面是预置的缩放选项,可以看到,还有一些缩放效果没有提供,可以自己通过setImageMatrix实现。比如,和FIT_CENTER相对的,使得宽和高都大于等于view,宽和高至少一个相等。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-09-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ImageView.ScaleType
  • 不同选项含义
    • CENTER
      • CENTER_CROP
        • CENTER_INSIDE
          • FIT_CENTER
            • FIT_END
              • FIT_START
                • FIT_XY
                  • MATRIX
                  相关产品与服务
                  图像处理
                  图像处理基于腾讯云深度学习等人工智能技术,提供综合性的图像优化处理服务,包括图像质量评估、图像清晰度增强、图像智能裁剪等。
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档