1

我在我的RelativeLayout中有几个EditTexts,并且在它的底部有一个按钮对齐。当弹出键盘时,我希望我的布局调整大小(因此,我使用的是android:windowSoftInputMode =“adjustResize”)并且也希望它可以滚动,因为在较小的屏幕中调整大小是不够的。当键盘出现时,滚动查看不会滚动

问题是我不能让它滚动!

我确实需要按钮来保持在屏幕的底部。

<?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" 
    android:background="#FFF"> 

    <!-- some hidden RelativeLayouts, filling the whole screen --> 

<RelativeLayout 
     android:id="@+id/form_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <ScrollView 
     android:layout_width="match_parent" android:layout_height="match_parent" 
      android:fillViewport="true" android:layout_above="@+id/ok_btn"> 

     <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" android:background="#99000000" android:visibility="visible"> 

      <View 
      android:id="@+id/shade" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:layout_alignTop="@+id/logradouro1" 
      android:background="#FFF" android:layout_marginTop="-30dp"/> 

      <!-- some visible EditTexts and TextViews here --> 

     </RelativeLayout> 

    </ScrollView> 

    <Button android:id="@+id/ok_btn" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" android:background="@color/verdeBotao" android:text="Cadastrar" 
      android:textColor="#FFF" android:layout_alignParentBottom="true"/> 

</RelativeLayout> 


</RelativeLayout> 

下面是2个屏幕截图来说明发生了什么。请注意,键盘启动后我无法滚动。 谢谢!

enter image description hereenter image description here

回答

0

我张贴类似的UI东西。为底部的按钮采用RelativeLayout。设置重力底部和你的按钮视图应该机器人:layout_alignParentBottom =“真

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/m_table_menu" > 

     <LinearLayout 
      android:id="@+id/layuserdetails" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="8dp" 
      android:orientation="horizontal" 
      android:padding="5dp" > 

      Yourviewss......i guess edittexts 

     </LinearLayout> 
    </ScrollView> 

//滚动按键布局

<RelativeLayout 
     android:id="@+id/m_table_menu" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:padding="0dp" > 

     <LinearLayout 
      android:id="@+id/laysharepost" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:gravity="bottom" 
      android:orientation="vertical" 
      android:padding="5dp" > 

//replace textview with buttonview.. 
      <TextView 
       android:id="@+id/share_tvcommentdone" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:background="@drawable/button_selector" 
       android:padding="10dp" 
       android:text="POST" 
       android:textColor="@android:color/white" /> 
     </LinearLayout> 
    </RelativeLayout> 
+0

你不使用滚动型?我认为我应该用它来处理小屏幕 – 2014-12-04 16:44:55

+0

我想我的问题与设置'android:layout_alignParentBottom =“true”'在视图内的某个滚动视图 – 2014-12-04 16:46:32

+0

无法将线性布局视为rootelement。试一试。 – 2014-12-04 16:50:51