gpt4 book ai didi

Android:如何以相同比例扩展矩形图像以适合屏幕

转载 作者:太空宇宙 更新时间:2023-11-03 11:40:36 25 4
gpt4 key购买 nike

我要在我的应用程序中设置以下矩形图像。

enter image description here

现在我试图在两边以相同的比例扩展图像,直到它适合屏幕。但我无法获得预期的图像。

enter image description here

到目前为止我的代码是:

<ImageView
android:id="@+id/imgid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/shayneward"
android:scaleType="fitXY"/>

图片被截断并不重要,但它应该以相同的比例在两边扩展,直到适合屏幕。

最佳答案

android:scaleType="fitXY" 更改为 android:scaleType="centerCrop" 以获得您想要的行为。

不同的缩放选项记录在 ImageView.ScaleType 下.

关于Android:如何以相同比例扩展矩形图像以适合屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11094970/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com