我在RelativeLayout的底部固定了一个EditText和一个Button。
当你点击EditText时,软键盘打开,但EditText和按钮消失了,但方式很奇怪。它们实际上就在那里,因为你可以打字,你也可以按下键盘上方的按钮,它会对触摸做出反应,但是。。。你实际上看不到它们。
不知道为什么,但这似乎是特定于屏幕分辨率的?它在我的NexusOne上坏了,但在我的LS670上工作。在带有WVGA800的模拟器上断开,但在HVGA上工作。
我有一个更复杂的layout.xml,但我设法将其归结为一个简单的例子:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/test_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/test_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/test_textButton"
/>
<Button
android:id="@id/test_textButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="OK"/>
</RelativeLayout>
编辑:
所以我越是深入研究,它似乎是布局引擎中的一个bug。当我点击EditText时,我可以看到EditText在键盘覆盖它之前向上移动。它只是不够高。这似乎与宽屏幕分辨率有关。如果我最终在编辑文本上加上100dip的边距,我几乎看不到它在键盘上方突出,而200dip使它大部分显示出来。再说一次,这在HVGA屏幕上运行良好。隐藏在键盘下面的按钮仍然对我在键盘上方的触摸做出反应,这很奇怪。
尝试将ScrollView设置为0dp
而不是fill_parent
。fill_parent
使其填充整个父对象的高度,从而与test_footer
重叠。