Android 如何使用ImageButtons管理TableRow的高度?

Android 如何使用ImageButtons管理TableRow的高度?,android,android-layout,android-tablelayout,Android,Android Layout,Android Tablelayout,我正试图有一个自定义键盘与桌面布局和图像按钮。到目前为止,我已经做到了 但是很明显,我在删除两个连续表格行之间的垂直间距时遇到了问题。有关守则如下: <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/numkeypad" android:orientation="vertical

我正试图有一个自定义键盘与桌面布局和图像按钮。到目前为止,我已经做到了

但是很明显,我在删除两个连续表格行之间的垂直间距时遇到了问题。有关守则如下:

        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:id="@+id/numkeypad"
                 android:orientation="vertical"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:stretchColumns="*"

                 android:layout_gravity="bottom"
                 android:visibility="visible"
                 android:background="@color/contents_text"
            >

        <TableRow
                android:layout_width="wrap_content"
                android:layout_height="60dp"
                android:layout_weight="1"
                >

            <ImageButton android:id="@+id/numkeypad_1"
                         android:layout_height="60dp"
                         android:layout_weight="0.33333333333333"
                    android:layout_width="wrap_content"
                    android:src="@drawable/k1"
                    >
            </ImageButton>
            <ImageButton android:id="@+id/numkeypad_2"
                    android:layout_weight="0.33333333333333"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/k2">
            </ImageButton>
            <ImageButton android:id="@+id/numkeypad_3"
                    android:layout_weight="0.33333333333333"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/k3">

            </ImageButton>
        </TableRow>

        <TableRow                     android:layout_width="wrap_content"
                                      android:layout_height="60dp"
                                      android:layout_weight="1">
            <ImageButton android:id="@+id/numkeypad_4"
                         android:layout_weight="0.33"
                         android:layout_width="wrap_content"
                         android:layout_height="match_parent"
                         android:src="@drawable/k4"
                    >
            </ImageButton>
            <ImageButton android:id="@+id/numkeypad_5"
                    android:layout_weight="0.33"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/k5">
            </ImageButton>

            <ImageButton android:id="@+id/numkeypad_6"
                         android:layout_weight="0.33"
                         android:layout_width="wrap_content"
                         android:layout_height="60dp"
                         android:src="@drawable/k6">

            </ImageButton>
        </TableRow>

有人能告诉我是什么造成了两排桌子之间的垂直间距,我怎样才能消除它


谢谢。

您看到的行为是由于您用于
图像按钮的
布局参数所造成的。
TableLayout
TableRow
是对其子项施加某些约束的小部件(关于使用的
Layoutparams
值)。布局中的
TableRow
应该如下 这:



表格行
表格行
中的视图上使用
布局权重
的目的是什么?嗯,我不太知道如何删除间距,因此,我尝试在所有位置都使用权重。我只是在验证它是否有效。移除权重,将
android:background=“@null”
添加到所有
ImageButtons
中,然后仔细检查
src
图像中的
ImageButtons
是否不包含您看到的空间。我照您说的做了,但没有帮助。垂直间距仍然存在。您确定没有通过自定义主题设置边距/填充吗?你能把
ImageButtons
使用的一幅图片张贴到某个地方吗?
  <TableRow
            android:layout_width="wrap_content"
            android:layout_height="60dp" >

        <ImageButton android:id="@+id/numkeypad_1"
                android:src="@drawable/k1" 
                android:background="@null" /> <!-- remove and possible padding from the Button drawable -->
        <ImageButton android:id="@+id/numkeypad_2"
                android:src="@drawable/k2" 
                android:background="@null" />
        <ImageButton android:id="@+id/numkeypad_3"
                android:src="@drawable/k3"
                android:background="@null" />
  </TableRow>