什么是ImageView.ScaleType.CENTER_INSIDE和FIT_CENTER之间的区别? [英] what's the difference between ImageView.ScaleType.CENTER_INSIDE and FIT_CENTER?

查看:1541
本文介绍了什么是ImageView.ScaleType.CENTER_INSIDE和FIT_CENTER之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能告诉ImageView.ScaleType.CENTER_INSIDE和ImageView.ScaleType之间的差异。 FIT_CENTER。

I can't tell the difference between ImageView.ScaleType.CENTER_INSIDE and ImageView.ScaleType. FIT_CENTER.

ImageView.ScaleType.CENTER_INSIDE

ImageView.ScaleType.CENTER_INSIDE

缩放图像均匀(保持图象的高宽比),以使图像的两个尺寸(宽度和高度)将等于或小于所述视图(负填充)的对应尺寸。

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).

ImageView.ScaleType。 FIT_CENTER

ImageView.ScaleType. FIT_CENTER

计算一个比例,将保持原来的src宽高比,但也将确保的src完全适合内部dst的。至少有一个轴(X或Y)将完全适合。其结果是中心内部的DST。

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.

有人能照亮两者之间的区别是什么?

Can someone illuminate the difference between the two?

推荐答案

FIT_CENTER是要确保在源完全适合的容器内,和水平或垂直轴将是准确

FIT_CENTER is going to make sure that the source completely fits inside the container, and either the horizontal or vertical axis is going to be exact.

CENTER_INSIDE即将图像居中在容器内,而不是使边缘完全匹配。

CENTER_INSIDE is going to center the image inside the container, rather than making the edges match exactly.

因此​​,如果有一个方盒子,这是10×10,并且是8×8的图像时,CENTER_INSIDE将是直接在箱的与2的源和目标容器之间的中间的

so if you had a square box that was 10" x 10" and an image that was 8"x8", the CENTER_INSIDE would be directly in the middle of the box with 2" between the source and the destination container.

使用的FIT_CENTER,即从上面的例子中相同的图像,将适合整个容器,因为侧面是相等的,并且有一个轴将要匹配目标。随着FIT_CENTER,如果你有一个盒子,这是5×10,这是5×7,图像将被按比例缩放图像,坐标轴的将适合,所以之一,但仍中心内部的图像目的地。

With the FIT_CENTER, that same image from the example above, would fit the entire container, because the sides are equal, and one axis is going to match the destination. With FIT_CENTER, if you had a box that was 5" x 10", and an image that was 5" x 7", the image would be proportionally scaled, so one of the axis's would fit, but would still center the image inside the destination.

它们是相似的,但一个是制成以使源将填充目标尽可能,而另一只中心目标内的图像。

They are similar, but one is made so that the source will fill the destination as much as possible, while the other just centers the image inside the destination.

。希望澄清一点

这篇关于什么是ImageView.ScaleType.CENTER_INSIDE和FIT_CENTER之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆