Android 为什么删除包含EditText的背景会增加行高?
有人知道当我删除包含EditText的背景属性时,为什么我的表行高度会增加吗Android 为什么删除包含EditText的背景会增加行高?,android,android-edittext,android-tablelayout,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
<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>
高度会发生变化,因为通过设置自定义背景,您将替换EditText默认背景,而默认背景可能不仅仅是颜色资源 检查以下类似问题:
使用android:layout\u height=“15dp”为什么layout\u height在有背景和没有背景的情况下会有不同的表现?我不知道,但这个问题也曾遇到过,但设置高度对我有帮助!嗯,我也注意到了同样的。。。但它会导致EditText的可单击区域垂直缩小。。此外,我不想明确指定高度,除非我必须。。。无论如何,谢谢你,也许最终我不得不听从你的建议。。。。