我正在为 Android 开发一个应用程序。
我有一个简单的布局。顶部有一个 CheckBox、一个 Spinner 和一个 Button,底部有一个两行 EditText,当 CheckBox 被选中时显示,另一个 EditText 覆盖中间的其余空间。
问题是当我在大的 EditText 上书写时,有时布局会超出屏幕顶部,结果我看不到我在写什么。
作为一种解决方案,我可以将我的布局设置为在键盘显示时调整大小(在 manifest.xml 上使用 android:windowSoftInputMode="adjustResize")但这并不好,因为我不希望 2 个 EditTexts 共享剩余空间屏幕上。
我的布局代码如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/button"
android:text="Push"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"/>
<CheckBox android:id="@+id/check_box"
android:text="Check"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />
<Spinner android:id="@+id/spinner"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText android:id="@+id/text_2"
android:hint="@string/hint_2"
android:inputType="textMultiLine"
android:maxLines="2"
android:gravity="top"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:visibility="gone" />
<EditText android:id="@+id/text_1"
android:hint="@string/hint_1"
android:inputType="textMultiLine"
android:gravity="top"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="@id/spinner"
android:layout_above="@id/text_2"
android:layout_alignWithParentIfMissing="true" />
</RelativeLayout>
PS这件事只发生在我的野火上,在模拟器上很少见。朋友的Desire HD完全没有问题。我不知道这是否有什么不同...
在此先感谢您的帮助。
安东尼斯