Android 图片根据设备屏幕尺寸更改图片尺寸

Android image change image dimensions according to device screen size

我有一个 imageView 宽度为 "match_parent"(两端有一些边距)。

由于不同的设备有不同的宽度,图像不会填满 imageView,而是在两端留下一些间隙,具体取决于我在哪个设备上查看它。

我试过 android:adjustViewBounds="true" 但这会拉伸图像以填充宽度,这会严重扭曲内容。

正确的方法是什么?我应该给 android 多个不同尺寸的图像副本(比如不同像素密度的多个可绘制文件夹)吗?

更新

尝试将 scaleType 设置为“fitXY”,但这仍在拉伸图像,无法保持纵横比。

这是我的 xml:

<ImageView
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="110dp"
        android:scaleType="fitXY"
        android:src="@drawable/inner_map"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/header" />

如果这很重要,我已将此图像的多个具有不同分辨率的副本插入不同的可绘制文件夹

<ImageView
    android:id="@id/img"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="centerCrop" />

https://developer.android.com/reference/android/widget/ImageView.ScaleType