2012-03-20 93 views
3

我需要一個包含頁眉和頁腳的片段。中間的內容(當然)需要滾動。到那裏一切都很順利。 但是在scrollview裏面需要一個edittext,所以在某個時刻鍵盤會出現。不幸的是,當我更改windowSoftInputMode來調整它隱藏標題時,鍵盤還會顯示頁腳。帶頁眉,滾動視圖和頁腳的android佈局,頁腳出現鍵盤

總之,我想實現的是頁腳停留在底部,但scrollview的內容向上滾動(當鍵盤將焦點放在edittext上時)。此外,標題需要始終可見。

有關如何完成此行爲的任何建議?

+0

我有同樣的問題... adjustPan並沒有真正做到這一點,因爲滾動不起作用(我的內容是在ScrollView中) – Ted 2013-01-13 13:43:27

+0

我在下面的鏈接中遇到類似的問題。我的活動有頂部工具欄作爲標題和包含頁腳按鈕的視圖層次結構。 http://stackoverflow.com/questions/10599451/how-to-make-an-android-view-scrollable-when-the-keyboard-appears/38210659#38210659 – 2016-07-05 19:13:09

回答

0

你試過android:isScrollContainer =「false」嗎?

+0

在scrollview?或頁腳?要麼...? – vanleeuwenbram 2012-03-20 10:55:36

+0

的滾動視圖?或頁腳?要麼...? 編輯:當我把scrollScrollContainer的scrollview它的行爲相同,當我使用AdjustPan,所以不是真的我想要 – vanleeuwenbram 2012-03-20 11:20:00

+0

你解決了這個問題@vanleeuwenbram? – Ted 2013-01-13 13:43:49

0

Android的頁眉頁腳和滾動內容(身體)

你可以嘗試以下方法:

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

    <LinearLayout 
     android:id="@+id/header" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:padding="10dp" > 

     <TextView 
      android:id="@+id/TextView01" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="header" 
      android:textSize="40sp" > 
     </TextView> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/footer" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:padding="10dp" > 

     <TextView 
      android:id="@+id/TextView02" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="footer" 
      android:textSize="40sp" > 
     </TextView> 
    </LinearLayout> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/footer" 
     android:layout_below="@id/header" > 

     <LinearLayout 
      android:id="@+id/body" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <EditText 
       android:id="@+id/edit1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit2" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit3" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit4" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit5" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit6" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit7" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <EditText 
       android:id="@+id/edit8" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" /> 

      <Button 
       android:id="@+id/btn" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Submit" /> 
     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 

添加android:windowSoftInputMode="adjustPan"到Android清單您的活動。