2012-03-20 65 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清单您的活动。

相关问题