【发布时间】:2016-05-17 16:54:47
【问题描述】:
这是我预期的输出图像:
对于输出图像中显示的每个数字和单词,我有一个图像按钮和单个图像的网格布局。
我为所有这些生成了 9 个补丁图像。现在,当我将其中一个图像用于单个按钮时,将布局宽度和高度设置为包装内容,它显示的太大了,如图所示:(第一个使用“src”属性,第二个使用 ImageButton 的“background”属性.)
但是当我指定一些默认的高度和宽度值(例如 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>
【问题讨论】:
标签: android android-layout button android-imagebutton