2011-04-17 101 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。

相關問題