2012-01-18 92 views
3

就像在發短信的應用程序中一樣,我希望鍵盤在引發時將對話框向上推。我目前遇到的問題是鍵盤實際上超出了我的對話框並且屏幕沒有滾動。如何在焦點時將EditText與鍵盤一起放置?

這裏就是我想:(沒有足夠的信譽發表圖片)

Image one (Before)

Image two (After)

看看它是如何很好地提高了?我該如何去做呢?

+0

Android SDK中應該能夠一旦你把重點放在EDITTEXT自動處理的是,在這裏看到的信息:http://developer.android.com/guide/topics/ui/themes .html – codejunkie 2012-01-18 14:28:28

回答

4

使用RelativeLayout並將您的EditText使用android:layout_alignParentBottom="true"它應該在顯示鍵盤時自動升起。

+0

非常好!這是我想要的,非常感謝。 現在,如果我在EditText下面有一個按鈕,我想用它來提出,那麼我該如何去做呢? – VicVu 2012-01-18 14:45:34

+0

在相對佈局中,您可以指定諸如'android:layout_above =「@ id/id_of_other_view」'和'android:layout_below =「@ id/id_of_other_view」'之類的東西。 – tidbeck 2012-01-19 09:00:58

1

//在您的清單xml文件中嘗試windowsoftinput模式。

windowSoftInputMode="adjustResize" 

adjustResize 0x10  Always resize the window: the content area of the window is reduced to make room for the soft input area. 

ref this

相關問題