问题描述
我已将Adobe XD的一些图像以PNG格式导入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" />
这些图像显示了填充的外观:
Example 2: ImageView is quite larger than the actual image.
反正有没有使ImageView完全包裹在图像上而没有填充的方法?
谢谢您的帮助。
解决方法
尝试使用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" />