我有一个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>
Run Code Online (Sandbox Code Playgroud) 当我在横向模式下在屏幕上显示EditText时,如果我点击EditText来调出软键盘,EditText会在两个维度上展开以占据键盘未占用的整个屏幕!键盘解除后,它将恢复正常大小.
我已经在我的手机上检查了其他商业应用程序,其中许多(但不是全部!)也做了同样的事情.EditText在TableRow中,在TableLayout中,如下所示:
android:id="@+id/editTextHeight"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="25"
android:hint="Height"
Run Code Online (Sandbox Code Playgroud)
(Android 2.2,Droid Incredible,FWIW)提前致谢!