将图像视图调整为图像 (Android Studio)

Adjust Image View to Image (Android Studio)

我想知道你是如何将一个ImageView的"hitbox"调整到里面的Image上的,这样图片周围就没有空的space了。我想做一个游戏,所以当你点击图像旁边的空白 space 时感觉很奇怪,但它仍然算作 "a click on the image"。我真的很感激帮助。 提前谢谢你。

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/soraka"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/image"
    android:adjustViewBounds="true"
    android:maxWidth="300dp"
    android:maxHeight="300dp"
    android:scaleType="fitXY"
    android:layout_alignParentEnd="false"
    android:layout_alignParentStart="false"
    android:cropToPadding="false"
    android:padding="0dp" />

首先在某些图像编辑器中打开您的图像并检查它是否填满了整个 canvas。第二 - 使用 android:scaleType="fitXY"。但要注意纵横比:

Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

同时删除 ImageView 中的所有填充和边距。