我要在我的应用程序中设置以下矩形图像。
现在我试图在两边以相同的比例扩展图像,直到它适合屏幕。但我无法获得预期的图像。
到目前为止我的代码是:
<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/