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. Vue.js 和 MVVM 小细节

    MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...

  2. AES加密

    package com.edu.hpu; import java.math.BigInteger; import java.security.MessageDigest; import java.se ...

  3. 快速搭建springmvc+spring data jpa工程

    一.前言 这里简单讲述一下如何快速使用springmvc和spring data jpa搭建后台开发工程,并提供了一个简单的demo作为参考. 二.创建maven工程 http://www.cnblo ...

  4. SDWebImage源码解读 之 NSData+ImageContentType

    第一篇 前言 从今天开始,我将开启一段源码解读的旅途了.在这里先暂时不透露具体解读的源码到底是哪些?因为也可能随着解读的进行会更改计划.但能够肯定的是,这一系列之中肯定会有Swift版本的代码. 说说 ...

  5. JavaScript基础知识总结(四)

    JavaScript语法 八.函数 函数就是完成某个功能的一组语句,函数由关键字function + 函数名 + 加一组参数定义: 函数在定义后可以被重复调用,通常将常用的功能写成一个函数,利用函数可 ...

  6. ASP.NET MVC原理

    仅此一文让你明白ASP.NET MVC原理   ASP.NET MVC由以下两个核心组成部分构成: 一个名为UrlRoutingModule的自定义HttpModule,用来解析Controller与 ...

  7. NSStringCompareOptions

    typedefNS_OPTIONS(NSUInteger, NSStringCompareOptions) { NSCaseInsensitiveSearch = 1,    //不区分大小写比较 N ...

  8. Maven安装

    开发分布式的商场系统,用到了一些新的技术,做一个记录和分享 这里讲一下maven安装 首先什么是Maven Maven作为一个构建工具,不仅帮我们自动化构建,还能抽象构建过程,提供构建任务实现.他跨平 ...

  9. Linux基础介绍【第四篇】

    Linux文件和目录的属性及权限 命令: [root@oldboy ~]# ls -lhi total 40K 24973 -rw-------. 1 root root 1.1K Dec 10 16 ...

  10. Storm介绍(一)

    作者:Jack47 PS:如果喜欢我写的文章,欢迎关注我的微信公众账号程序员杰克,两边的文章会同步,也可以添加我的RSS订阅源. 内容简介 本文是Storm系列之一,介绍了Storm的起源,Storm ...