ImageButton 图像未调整为更小的尺寸

ImageButton image not resizing to smaller size

这是我预期的输出图像:

对于输出图像中显示的每个数字和单词,我都有图像按钮和单独图像的网格布局。

我为它们全部生成了 9 个补丁图像。现在,当我将其中一个图像用于单个按钮,布局宽度和高度设置为包装内容时,它显示太大,如图所示:(第一个使用 "src" 属性,第二个使用 "background" ImageButton 的属性。)

但是当我指定一些默认的高度和宽度值时,例如 50 dp,图像变得太小,甚至看不到数字,如下所示。

布局代码为

    <GridLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:id="@+id/numberGrid"
    android:layout_below="@+id/amountTextView"
    android:layout_gravity="center"
    android:layout_marginTop="9dp"
    android:layout_marginLeft="75dp"
    android:columnCount="3"
    android:rowCount="5"
    >
    <ImageButton android:text="1" />
    <ImageButton android:text="2" />
    <ImageButton android:text="3" />
    <ImageButton android:text="4" />
    <ImageButton android:text="5" />
    <ImageButton android:text="6" />
    <ImageButton android:text="7" />
    <ImageButton android:text="8" />
    <ImageButton android:text="9" />
    <ImageButton android:text="0" 
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:scaleType="center"
     android:src="@drawable/img_btn_0"
     />
    <ImageButton android:text="." />
    <ImageButton android:text="DEL" />
    <ImageButton android:text="CLEAR"
        android:layout_columnSpan="2"
        />
    <ImageButton android:text="OK" />
</GridLayout>

尝试在 dp 中指定一些高度和宽度,并将比例类型设置为 "centerCrop" 而不是 "center"。

<ImageButton
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:src="@drawable/img_btn_0"
    android:scaleType="centerCrop"/>