CENTER_INSIDE和FIT_CENTER比例类型有什么区别? [英] What's the difference between CENTER_INSIDE and FIT_CENTER scale types?

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

问题描述

我无法区分 ImageView.ScaleType.CENTER_INSIDE ImageView.ScaleType.FIT_CENTER

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

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.

所以如果你有一个10x 10的方框和一个8x8的图像,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,如果你有一个5x 10的盒子和一个5x 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.

希望澄清一点

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

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