2012-05-08 43 views
3

我正在使用此登錄屏幕,並且希望在顯示IME時調整所有字段,文本和按鈕的大小。我已經在androidManifest.xml中使用了android:windowSoftInputMode =「adjustResize」,但我仍然在其他人的下面找到了一些元素。如何在顯示軟鍵盤時保持所有字段和文本可見

如果TextView「Cadastre Agora」(id = cadastrar)仍然被虛擬鍵盤所覆蓋,我無所謂。但是,只要有幾個元素,我試圖至少使EditTexts(和他們的TextViews)和按鈕可見。

我發現這個沒有答案的問題,可能是一個有趣的方法:HTTP://stackoverflow.com/問題/ 6484024 /軟鍵盤保持一視後的固定而移動的,其他

感謝幫助!

屏幕無IME:http://imageshack.us/photo/my-images/138/semttulo2mr.png/

屏幕與IME(TextView1被隱藏起來):http://imageshack.us/photo/my-images/404/semttulo3xw.png/

#2抱怨我的代碼的格式,所以我在這裏上傳的xml文件:HTTPS://rapidshare.com /files/1767398103/login.xml 我不能發佈超過2個鏈接,這就是爲什麼我會在其中放置空格。

回答

2

在這種情況下,我會說你的初始佈局(沒有鍵盤顯示)已經有問題了。鑑於您正在創建純粹是登錄屏幕的內容,將所有控件放置在屏幕的上半部分並在用戶訪問該頁面時自動顯示鍵盤是可以接受的。這使得用戶的體驗更加快速,並且節省了您必須提供靈活的佈局。

但是,如果您想嘗試在兩個視圖中使佈局工作,則需要將控件之間的間距更改爲動態。

例如:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width = "fill_parent" 
    android:layout_height = "fill_parent" 
    android:orientation="vertical" 
    > 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- Username Controls here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- Password Controls here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- Login Button here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- TextView here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
</LinearLayout> 

爲了這個正常工作,所有的垂直填補必須從控制拆下,用標籤的文本框之間填充的除外。

+0

使用如此多的'LinearLayout'對於性能來說**性能差。 @Lucas,請嘗試檢查[Android IME選項](http://developer.android.com/resources/articles/on-screen-inputs.html) – thepoosh

+0

確實,它可能會像簡單的View對象一樣正常工作。 – Scott

+0

這對我有用:D我在下面粘貼了我的代碼。謝謝@Scott。 –

相關問題