我需要在我的应用程序中创建四个 imageButton
。每当我将 JPEG 图像插入 Android Studio 并将其放在 imageButton
上时,按钮的大小就会变大,以至于图像不适合按钮。
我需要按钮保持与我制作它相同的大小,并且需要图像很好地适合并位于按钮的中心。我已经尝试了一切。有谁知道如何做到这一点?这可以用任何格式的任何大小的图像来完成吗?
最佳答案
要使您的图像填充 ImageButton
然后使用 - android:scaleType="fitXY"
<ImageButton
android:id="@+id/TextButton"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="0.5"
android:scaleType="fitXY"
android:src="@drawable/jpeg_image" />
关于android - 如何使图像适合android中的imageButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29201653/