我有一个EditText
和一个Button
在同一行上并排放置。看起来很好,但是当用户输入大量文本时,EditText
会被重新调整大小,导致Button
被挤压。
我将EditText
和Button
都设置为layout_width="wrap_content"
。"fill_parent"
会破坏布局,而且我不想使用绝对尺寸-现在的样式在横屏和竖屏模式下都很好看,我只是不希望EditText
改变大小。
我的布局:
<TableLayout
android:id="@+id/homelayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow>
<TextView
android:id="@+id/labelartist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Find artists:" />
</TableRow>
<TableRow>
<EditText
android:id="@+id/entryartist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="@android:drawable/editbox_background"
android:editable="true"
android:padding="5px"
android:singleLine="true" />
<Button
android:id="@+id/okartist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:text="Search" />
</TableRow>
</TableLayout>
android:stretchColumns="x"
,其中“x”是包含您不想自动调整大小的EditText
的列位置。 - Caumons