2011-04-17 108 views
0

我正在为Android开发应用程序。当虚拟键盘出现时,EditText有时会熄灭屏幕

我有一个简单的布局。在顶部有一个CheckBox,一个微调器和一个按钮,底部有两行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> 

附:这种情况只发生在我的Wildfire上,在模拟器上非常罕见。朋友的Desire HD根本没有任何问题。我不知道这是否有什么区别...

在此先感谢您的帮助。

安东尼斯

回答

0

我有完全相同的问题。我已经测试过,并且这只发生在多行模式下的EditText以及SoftInputMode设置为adjustPan时。这很可能是一个Android错误。

我找到的唯一解决方案是删除adjustPan。

相关问题