[英]soft keyboard hides my edittext - android
我的布局中有一個編輯文本,但是單擊此編輯文本后,軟鍵盤會出現,並覆蓋整個文本字段。 結果,我看不到我在輸入什么,這很煩人。 誰能告訴我是否有解決方法?
編輯:我還試圖將整個布局包裝在滾動視圖中。 我以這種方式聽說可以得到想要的東西,但仍然沒有任何反應。 這是我的布局代碼:
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:id="@+id/mainLayoutMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" >
.................... Bunch of View....................
</RelativeLayout>
</ScrollView>
我還可以做些什么?
PS我也嘗試在清單文件中設置以下屬性:
android:windowSoftInputMode="adjustPan"
和:
android:windowSoftInputMode="adjustResize"
乃至:
android:windowSoftInputMode="adjustPan|adjustResize"
但是什么都行不通。 一切都會導致相同的結果-軟鍵盤隱藏了編輯文本字段。
您可以做的一件事是使您的根(父)布局具有android:layout_height="wrap_content"
,這樣,在召喚軟鍵盤時, View
將自身失效,並相應地調整大小,並且如果EditText
對齊此View
底部(出於這個原因,我建議您將RelativeLayout
用作父級,它也會提高。
編輯:
另一件事:
嘗試將此屬性設置到清單中:
<application ... >
<activity
android:windowSoftInputMode="adjustResize" ... >
...
</activity>
...
</application>
然后更改您的根目錄布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@drawable/background_grey"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<!-- Your Layout content here -->
</RelativeLayout>
</ScrollView>
我不知道任何其他解決方案,這主要是由於沒有已知的回調或某種事件來處理代碼中的此類行為(軟鍵盤生成)。
因此,一切都取決於布局設計和屬性,以及android系統如何根據此處理Input事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.