0

我已经将一些 PNG 格式的图像从 Adob​​e XD 导入到 Android Studio。这些图像似乎带有额外的填充。我试图用导入图像的大小(在本例中为消息)填充 ImageView。

这是我的xml:

<ImageView
    android:src="@drawable/messages"
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    tools:layout_editor_absoluteX="79dp"
    tools:layout_editor_absoluteY="184dp" />

这些图像显示了填充的样子:

示例 1:图像有填充

示例 2:ImageView 比实际图像大很多。

无论如何要让 ImageView 在没有填充的情况下完全环绕图像吗?

感谢您的帮助。

4

1 回答 1

0

尝试使用 android:scaleType:

<ImageView
    android:src="@drawable/messages"
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitXY" 
    tools:layout_editor_absoluteX="79dp"
    tools:layout_editor_absoluteY="184dp" />
于 2020-10-15T06:25:31.790 回答