【问题标题】:Does Android have Aspect Fill concept similar to iOS?Android 是否有类似于 iOS 的 Aspect Fill 概念?
【发布时间】:2012-07-26 00:44:57
【问题描述】:

在 Android 中是否有任何与 iPhone Aspect Fill 相关的概念。我想在 imageview 上的我的 android 图像中包含同样的概念。请给我这个概念的代码sn-p?

【问题讨论】:

标签: android


【解决方案1】:

如果您想要一个在保持适当纵横比的同时可以上下缩放的 ImageView,请将其添加到您的 XML 中:

android:adjustViewBounds="true"
android:scaleType="centerCrop"

Look这个。

【讨论】:

  • 此答案不正确,因为“fitCenter”不提供与 iOS“Aspect Fill”相同的行为。您需要改用 scaleType="centerCrop"。
  • 没有正确填满屏幕
  • 如果有人正在寻找类似于 ios 中的 Apsect FIt 的属性(即图像将保持其纵横比并且至少适合 (X 或 y) 之一)然后 android:scaleType = "fitCenter" 可以。
【解决方案2】:

我尝试了 fitCenter 但它不起作用,我最终使用了

android:scaleType="centerCrop"
android:adjustViewBounds="true"

【讨论】:

    【解决方案3】:

    测试过!!! adjustViewBounds 需要与 scaleType centerCrop 一起为 false 以匹配 iOS 的 UIViewContentModeScaleAspectFill 行为

    android:adjustViewBounds="false"
    android:scaleType="centerCrop"
    

    【讨论】:

      猜你喜欢
      • 2014-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-22
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多