2011-09-07 104 views
1

調整我掙扎,對齊屏幕底層軟件鍵盤的底部兩個按鈕相處一個小的EditText。基本上我的問題是,每次我打開我的活動時間(標記有adjustResize   |   stateAlwaysVisible)和佈局圖:的Android adjustResize佈局,軟鍵盤

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:gravity="bottom" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_alignParentBottom="true"> 

    <LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/soft_input_edit_placeholder"> 
     <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/editText1"> 
      <requestFocus></requestFocus> 
     </EditText> 
    </LinearLayout> 
    <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:weightSum="2" android:id="@+id/soft_input_layout_buttons"> 
     <Button android:layout_width="0dp" android:text="xxx Submit xxx" android:layout_height="wrap_content" android:id="@+id/soft_input_button_submit" android:layout_weight="1"></Button> 
     <Button android:layout_width="0dp" android:text="xxx Cancel xxx" android:layout_height="wrap_content" android:id="@+id/soft_input_button_cancel" android:layout_weight="1"></Button> 
    </LinearLayout> 
</LinearLayout> 

鍵盤向上滑動時,它會調整活動,使僅編輯文本可見,當我隱藏它(至少在鍵盤上有一個按鈕,可以讓我隱藏),佈局保持位置,也就是說,它永遠不會滑回了,不覆蓋屏幕的一半。

我讀到,在大多數情況下,對齊,通過引入一些可擴展的控制佈局實現了,但我真的不希望有任何形式的ListView存在的;我嘗試過使用RelativeLayout,仍然沒有去。將一個嵌入另一個 - 仍然沒有運氣。我會爲你可能有,我跑出來的想法有任何建議非常感謝..

謝謝!

回答

2

的問題是所有選定的主題。我的活動在清單中應用了全屏主題(我不知道它可能會以這種方式影響視圖);將其更改爲是非全屏已經解決了我的問題(雖然它不能僅僅是任何其他主題)

我通過Theme.Translucent和佈局主題活動主題設定爲主題實現我的目標(根本沒有主題);應用@android:繪製/ bottom_bar到主的LinearLayout終於主要佈局的重心設置爲底部給了我一直在尋找的結果。