【发布时间】:2019-08-21 13:13:04
【问题描述】:
我有一个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" />
如果这很重要的话,我已经将该图像的不同分辨率的多个副本插入到不同的可绘制文件夹中
【问题讨论】:
标签: android imageview android-drawable