Android是否具有与iOS类似的Aspect Fill概念?

ADI*_*DIT 26 android

在Android中我是否有任何与IPhone Aspect Fill相关的概念.我想在imageview上的android图像中包含这个相同的概念.请给我这个概念的代码片段?

Chi*_*rag 62

如果您希望ImageView在保持适当的宽高比的同时向上和向下缩放,请将其添加到XML:

android:adjustViewBounds="true"
android:scaleType="centerCrop"
Run Code Online (Sandbox Code Playgroud)

这个.

  • 这个答案是不正确的,因为"fitCenter"不提供与iOS"Aspect Fill"相同的行为.您需要使用scaleType ="centerCrop". (10认同)
  • 不能正确填满屏幕 (2认同)
  • 如果有人在 ios 中寻找类似于 Apsect FIt 的属性(即图像将保持其纵横比并且至少适合(X 或 y)之一),那么 android:scaleType = "fiteCenter" 就可以了。 (2认同)

zam*_*ono 30

我尝试了fitCenter,它没有用,我最终使用了

android:scaleType="centerCrop"
android:adjustViewBounds="true"
Run Code Online (Sandbox Code Playgroud)