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编写)

ImageView缩放选项的更多相关文章

  1. ImageView 缩放

    <ImageView android:id="@+id/imageview" android:layout_width="wrap_content" an ...

  2. MotionEvent分析及ImageView缩放实现

    这个类在各种View和用户的手势操作之间的交互存在很大的自定义空间.要理解清楚这个类的一些特性和意义,对自定义的新型控件很有帮助 先翻译一下开发者文档的描述 Overview Motion event ...

  3. Android ImageView 详述

    结构 继承关系 public classView.OnClickListner extendsView java.lang.Object android.view.View android.widge ...

  4. 手势 触摸【缩放】GestureDetector MotionEvent 案例

    GestureDetector和ScaleGestureDetector示例 /**  * 演示[单点触摸手势识别器]  * 演示[缩放手势识别器]最简单的使用  * @author 白乾涛  */ ...

  5. UIView---汇总

    视图.绘图.贴图.手势.变形.布局.动画.动力.特效 UIBezierPath.UIGestureRecognizer.CGAffineTransform.frame.bounds.center.tr ...

  6. Android:ScaleType与Matrix相关

    关于ScaleType,网上介绍这个枚举对象的文章很多了,不过基本都只是介绍了它的效果.我在做可缩放移动的ImageView时,为了实现图片的缩放和拖动,需要记录图片的原始Matrix,在使用过程中发 ...

  7. PROC 文件系统调节参数介绍(netstat -us)

    转自:http://www.cnblogs.com/super-king/p/3296333.html /proc/net/* snmp文件 Ip: ip项 Forwarding        : 是 ...

  8. android 如何正确使用 泛型 和 多参数 “偷懒”

    我要实现这样一个标题栏 共 4 个选项,采用布局是一个 TextView 对应一个小三角 ImageView,各个选项没被点击时,字体颜色是 黑色,小三角不显示,点击后,字体变色,小三角居下显示,同时 ...

  9. IOS开发基础知识--碎片10

    1:如何给表格单元列增加选择时的背影效果 if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCel ...

随机推荐

  1. 简单入门canvas - 通过刮奖效果来学习

    一 .前言 一直在做PC端的前端开发,从互联网到行业软件.最近发现移动端已经成为前端必备技能了,真是不能停止学习.HTML5新增的一些东西,canvas是用的比较多也比较复杂的一个,简单的入门了一下, ...

  2. HTML5 Boilerplate - 让页面有个好的开始

    最近看到了HTML5 Boilerplate模版,系统的学习与了解了一下.在各种CSS库.JS框架层出不穷的今天,能看到这么好的HTML模版,感觉甚爽.写篇博客,推荐给大家使用.   一:HTML5 ...

  3. $.extend()的实现源码 --(源码学习1)

    目标: $.extend({         add:function(a,b){             return a + b;         }     }) console.log($.a ...

  4. 学习ASP.NET Core, 怎能不了解请求处理管道[5]: 中间件注册可以除了可以使用Startup之外,还可以选择StartupFilter

    中间件的注册除了可以借助Startup对象(DelegateStartup或者ConventionBasedStartup)来完成之外,也可以利用另一个叫做StartupFilter的对象来实现.所谓 ...

  5. .NET Core的日志[3]:将日志写入Debug窗口

    定义在NuGet包"Microsoft.Extensions.Logging.Debug"中的DebugLogger会直接调用Debug的WriteLine方法来写入分发给它的日志 ...

  6. MySQL中interactive_timeout和wait_timeout的区别

    在用mysql客户端对数据库进行操作时,打开终端窗口,如果一段时间没有操作,再次操作时,常常会报如下错误: ERROR (HY000): Lost connection to MySQL server ...

  7. C# salt+hash 加密

    一.先明确几个基本概念 1.伪随机数:pseudo-random number generators ,简称为:PRNGs,是计算机利用一定的算法来产生的.伪随机数并不是假随机 数,这里的" ...

  8. 使用HTML5的cavas实现的一个画板

    <!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-e ...

  9. JavaScript中的this

    本文尽量避免概念性的讲解,那样太抽象 所以下面以一些简单的例子,从易到难对this的用法总结 1.方法中的this会指向当前执行该方法的对象 如: var name = "window&qu ...

  10. ubuntu安装ANSYS17.2全过程

    本次介绍在Ubuntu kylin1604下安装Ansys 17.2的全部过程. 1 安装文件准备 关于ANSYS的软件安装文件,在网络上可以找到.这里采用SSQ版本的安装文件,如图所示,包含一个名为 ...