What#39;s the difference between CENTER_INSIDE and FIT_CENTER scale types?(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.
因此,如果您有一个 10" x 10" 的方形框和一个 8"x8" 的图像,则 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" x 10" 的框和一个 5" x 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 比例类型有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CENTER_INSIDE 和 FIT_CENTER 比例类型有什么区别?
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01