为什么删除包含EditText的背景会增加行高?

时间:2014-01-05 04:32:08

标签: android android-edittext android-tablelayout

当我删除包含EditText的背景属性时,有人知道我的表行高度增加的原因吗?

<TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="1,3" >

        <TableRow
            android:id="@+id/tr3a"
            android:padding="2.5dp"
            android:background="@color/col1"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1" >

            <TextView
                android:id="@+id/lab_bookname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/bookname" />

            <EditText
                android:id="@+id/bookname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_span="3"
                android:textSize="14sp"
                android:background="@color/white" // FOR VIEW 1, I REMOVE THIS LINE, NO OTHER CHANGE
                android:hint="@string/definputtext2" />

        </TableRow>

enter image description here

1 个答案:

答案 0 :(得分:0)

高度发生变化,因为通过设置自定义背景,您将替换EditText默认背景,这可能不仅仅是一种颜色资源。

检查以下类似问题:

Problem with EditText background (android)

EditText dimensions change if I use color as a background?