2010-06-04 48 views
10

我有一個簡單的用戶界面:EditText應該位於SurfaceView下方。 我使用RelativeLayout來安排這兩個視圖。當顯示虛擬鍵盤和涉及SurfaceView時,Android的EditText被隱藏

現在,當我點擊EditText打開虛擬鍵盤時,SurfaceView滑動但EditText被隱藏並且不顯示鍵入的字符串。

複製,使用下面的佈局XML代碼:

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/RelativeLayout01" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent"> 

<SurfaceView 
android:id="@+id/SurfaceView01" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 
</SurfaceView> 

<EditText 
android:id="@+id/EditText01" 
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:layout_alignParentLeft="true" 
android:layout_alignParentBottom="true" 
android:selectAllOnFocus="true" 
android:textStyle="normal" 
android:singleLine="true"> 
</EditText> 

</RelativeLayout> 

主要活動類只需要顯示的佈局。當我啓動程序並點擊EditText時,出現虛擬鍵盤,但EditText字段不見了。

也許RelativeLayout導致的問題,但我不知道如何重現與另一個佈局類相同的佈局。

歡迎任何建議,我非常感謝您的幫助。

謝謝。

編輯:

下面是兩個截屏,一個顯示的EditText在底部沒有虛擬鍵盤,用一個虛擬鍵盤,但沒有的EditText。有意思的是,SurfaceView和EditText實際上是向上移動的,EditText只是消失了。順便說一句,如果它靠近EditText,這也會發生在按鈕上。

EditText below a SurfaceView (left); EditText is gone (right)

+0

你可能會考慮附上一對屏幕截圖,一個隱藏軟鍵盤(即「正常」 ),然後點擊「EditText」彈出鍵盤。您可以使用DDMS製作截圖。 – CommonsWare 2010-06-05 00:11:11

+1

此錯誤已報告:http://code.google.com/p/android/issues/detail?編號= 11676 – Jan 2010-11-29 21:29:28

回答

8

thread about this bug一個評論者建議,這是很容易由SurfaceViewGLSurfaceView的背景色與mSurfaceView.setBackgroundColor(Color.TRANSPARENT);設置爲透明,以及來解決這個問題。

在Samsung Galaxy Tab 10.1上的Honeycomb(v13)上按下EditText時出現了此問題。問題是在GLSurfaceView被調整大小後,在它的位置仍然是一個黑色矩形,覆蓋了EditText。這個解決方案通過使錯誤的矩形透明起作用,因此可以看到EditText

+2

非常感謝,我希望我能+100! – 2012-09-19 14:49:37

1

添加如下代碼,爲您的活動的AndroidManifest.xml android:windowSoftInputMode="adjustPan"

0

是的,這是正確的! 爲您的活動添加如下代碼在你的AndroidManifest.xml android:windowSoftInputMode="adjustPan"

而在你編輯文本,只需添加:

android:imeOptions="flagNoFullscreen" 
0

我發現它具有在不同設備上不同的結果,然後我用滾動型爲根視圖並把佈局放入ScrollView,當使用fullScreen模式時它工作正常。並且一定要設置android:fillViewport =「true」,如果你還有問題,請告訴我[email protected]