zoukankan      html  css  js  c++  java
  • ImageView缩放选项

    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,宽和高至少一个相等。

    (本文使用Atom编写)

  • 相关阅读:
    Eclipse下安装Pydev以及Helloworld实例 分类: Python 2015-07-23 23:30 29人阅读 评论(0) 收藏
    Eclipse下安装Pydev以及Helloworld实例
    Selenium学习笔记之013:控制滚动条到底部
    iOS开发Embedded dylibs/frameworks are only supported on iOS 8.0 and later for architecture armv7的解决方法
    UIView 和 CALayer 的区别和联系。
    iOS 防止数组越界的解决方法
    iOS中集成ijkplayer视频直播框架
    解析数据时,快速查看当前需要创建的数据模型的所有属性,不用每个都写,直接打印粘贴
    iOS开发中,能够方便使用的Xcode插件
    UIButton图片拉伸方法(很多需要按钮的地方我们只需要一张小图来进行缩放)
  • 原文地址:https://www.cnblogs.com/everhad/p/5913386.html
Copyright © 2011-2022 走看看