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

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

到目前为止我的代码是:
<ImageView
android:id="@+id/imgid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/shayneward"
android:scaleType="fitXY"/>
Run Code Online (Sandbox Code Playgroud)
它不关心图像被切断,但它应该以相同的比例在两侧扩展,直到它适合屏幕.
尝试使用这个:
android:scaleType="centerCrop"
Run Code Online (Sandbox Code Playgroud)
从 Android 文档中,中心裁剪执行以下操作:
均匀缩放图像(保持图像的纵横比),使图像的两个尺寸(宽度和高度)等于或大于视图的相应尺寸(减去填充)。
请参阅ImageView.ScaleType 此处的文档。
| 归档时间: |
|
| 查看次数: |
6246 次 |
| 最近记录: |