2017-06-16 77 views
1

看起來像一個簡單的問題,但我找不到任何解決方案。當軟鍵盤出現時,將視圖鎖定到屏幕頂部

我的佈局,層次結構也很簡單:

<RelativeLayout 
    ...> 
    <LinearLayout 
     android:id="@id/header" 
     android:layout_alignParentTop="true" 
     ...> 
    /> 
    <RecyclerView 
     ...> 
    /> 
    <RelativeLayout 
     android:id="@id/footer" 
     android:layout_alignParentBottom="true" 
     ...> 
    /> 
</RelativeLayout> 

會發生什麼: 我有一個EditText,這是頁腳佈局的孩子。當它獲得焦點時,軟鍵盤出現,整個佈局被拉起。

我想達到的目標: ......,在softkeyboard出現,標題將保持在頂部,頁腳將softkeyboard(就像現在)上面拉,唯一的調整視圖會RecyclerView

我嘗試了幾十種組合與windowSoftInputMode,結合我的佈局與ScrollView ...但沒有什麼幫助。

它一定很容易,不是嗎?

編輯:佈局DialogFragment

回答

0

的內容視圖中,您可以添加你的整個代碼,所以我可以測試,這將幫助我們找出和詳細的問題。雖然我嘗試了一些工作正常的東西。檢查下面

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<RelativeLayout 
    android:id="@+id/view_header" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentTop="true" 
    android:background="#00ff00" /> 

<RecyclerView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/view_header" 
    android:layout_above="@+id/view_footer" 
    android:background="#006655"/> 

<RelativeLayout 
    android:id="@+id/view_footer" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentBottom="true" 
    android:background="#009911" > 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 


</RelativeLayout> 

我的回答