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编写)
ImageView缩放选项的更多相关文章
- ImageView 缩放
<ImageView android:id="@+id/imageview" android:layout_width="wrap_content" an ...
- MotionEvent分析及ImageView缩放实现
这个类在各种View和用户的手势操作之间的交互存在很大的自定义空间.要理解清楚这个类的一些特性和意义,对自定义的新型控件很有帮助 先翻译一下开发者文档的描述 Overview Motion event ...
- Android ImageView 详述
结构 继承关系 public classView.OnClickListner extendsView java.lang.Object android.view.View android.widge ...
- 手势 触摸【缩放】GestureDetector MotionEvent 案例
GestureDetector和ScaleGestureDetector示例 /** * 演示[单点触摸手势识别器] * 演示[缩放手势识别器]最简单的使用 * @author 白乾涛 */ ...
- UIView---汇总
视图.绘图.贴图.手势.变形.布局.动画.动力.特效 UIBezierPath.UIGestureRecognizer.CGAffineTransform.frame.bounds.center.tr ...
- Android:ScaleType与Matrix相关
关于ScaleType,网上介绍这个枚举对象的文章很多了,不过基本都只是介绍了它的效果.我在做可缩放移动的ImageView时,为了实现图片的缩放和拖动,需要记录图片的原始Matrix,在使用过程中发 ...
- PROC 文件系统调节参数介绍(netstat -us)
转自:http://www.cnblogs.com/super-king/p/3296333.html /proc/net/* snmp文件 Ip: ip项 Forwarding : 是 ...
- android 如何正确使用 泛型 和 多参数 “偷懒”
我要实现这样一个标题栏 共 4 个选项,采用布局是一个 TextView 对应一个小三角 ImageView,各个选项没被点击时,字体颜色是 黑色,小三角不显示,点击后,字体变色,小三角居下显示,同时 ...
- IOS开发基础知识--碎片10
1:如何给表格单元列增加选择时的背影效果 if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCel ...
随机推荐
- myeclipse学习总结一(在MyEclipse中设置生成jsp页面时默认编码为utf-8编码)
1.每次我们在MyEclispe中创建Jsp页面,生成的Jsp页面的默认编码是"ISO-8859-1".在这种情况下,当我们在页面中编写的内容存在中文的时候,就无法进行保存.如下图 ...
- EditText 基本用法
title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...
- Twproject Gantt开源甘特图功能扩展
1.Twproject Gantt甘特图介绍 Twproject Gantt 是一款基于 jQuery 开发的甘特图组件,也可以创建其它图表,例如任务树(Task Trees).内置编辑.缩放和 CS ...
- 程序员必须要知道的Hadoop的一些事实
程序员必须要知道的Hadoop的一些事实.现如今,Apache Hadoop已经无人不知无人不晓.当年雅虎搜索工程师Doug Cutting开发出这个用以创建分布式计算机环境的开源软...... 1: ...
- TYPESDK手游聚合SDK服务端设计思路与架构之二:服务端设计
在前一篇文中,我们对一个聚合SDK服务端所需要实现的功能作了简单的分析.通过两个主要场景的功能流程图,我们可以看到,作为多款游戏要适配多个渠道的统一请求转发中心,TYPESDK服务端主要需要实现的功能 ...
- React Native Android gradle下载慢问题解决
很多人会遇到 初次运行 react-native run android的时候 gradle下载极慢,甚至会失败的问题 如下图 实际上这个问题好解决的 首先 把对应版本的gradle下载到本地任意一个 ...
- Android开发学习—— 创建项目时,不是继承activity,而是继承ActionBarActivity
对于我们新建android项目时, 会 继承ActionBarActivity. 我们在新建项目时, 最小需求的sdk 选择 4.0以上版本.这样 新建的android项目就是继承activity了!
- Python学习实践------正向最大匹配中文分词
正向最大匹配分词: 1.加载词典文件到集合中,取词典文件中最大长度词的length 2.每次先在句子中按最大长度分割,然后判断分割的词是否存在字典中,存在则记录此词,调整起始点. 3.不存在则按最大长 ...
- [Xamarin] 透過Native Code呼叫 JavaScript function (转帖)
今天我們來聊聊關於如何使用WebView 中的Javascript 來呼叫 Native Code 的部分 首先,你得先來看看這篇[Xamarin] 使用Webview 來做APP因為這篇文章至少講解 ...
- ubuntu-14.04-server配置Jexus --安装步骤记录
作者:郝喜路 个人主页:http://www.cnicode.com 博客地址:http://haoxilu.cnblogs.com 说明:我是Linux菜鸟,自己尝试配置Jexus服务 ...