Android ImageView 的 ScaleType 属性

Android ImageView 的 ScaleType 属性用来表示图片的显示方式。总共有8种取值,取值的范围定义在 android.widget.ImageView.ScaleType 这个枚举类型里。

ImageView.ScaleType.CENTER : 居中,但不缩放。图片超出控件的部分不显示,小于控件的部分就留白。Center the image in the view , but perform no scaling .

ImageView.ScaleType.CENTER_CROP : 居中,缩放,裁剪。对图片进行等比例缩放,图片的宽高等于或大于控件对应的宽高,所以会有部分不能被显示出来。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). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerCrop".

ImageView.ScaleType.CENTER_INSIDE  : 居中,缩放。对图片进行等比例缩放,图片的宽高等于或小于控件相对应的宽高。和FIT_CENTER 不同的是,图片可能的宽高都同时可能比控件对应的宽高小。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). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerInside".

ImageView.ScaleType.FIT_CENTER : 居中,参考 android.graphics.Matrix.ScaleToFit.CENTER . 等比例缩放,但最少有一个边与控件对应的边是相等的。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 centered inside dst.

ImageView.ScaleType.FIT_END: 居下,等比例缩放,也是最少有个边与控件对应的边是相等的。参考 android.graphics.Matrix.ScaleToFit.END  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.

ImageView.ScaleType.FIT_START:居上,等比例缩放,最少有个边与控件对应的边是相等的。参考 android.graphics.Matrix.ScaleToFit.START  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.

ImageView.ScaleType.FIX_XY:不等比例缩放,X轴和Y轴都和控件对应的边相等,图片可能被拉伸。参考 android.graphics.Matrix.ScaleToFit.FILL  Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

ImageView.ScaleType.MATRIX:根据一个矩阵对图片进行缩放。Scale using the image matrix when drawing. The image matrix can be set using setImageMatrix(Matrix). From XML, use this syntax: android:scaleType="matrix".

 

原文地址: http://www.binkery.com/post/385.html  

转载于:https://www.cnblogs.com/binkery/p/3958002.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值