2013-05-14 73 views
0

下方添加的RelativeLayout消失时,这里的画像UI我从我的布局需要的简化版本:的ListView行一个ListView

Portrait desired

它上方的另一布局一个ListView。

的复杂性在于,我希望整个底部布局(在这种情况下“将Button2”)可见,当大量的线被添加到的EditText:

Landscape desired

我一直在努力通过在LinearLayout中嵌套一个RelativeLayout来实现这一点。不幸的是,当我用EditText得到我想要的效果时,ListView就消失了,例如,

ListView disappears

我试过的替代品的负荷,但似乎没有达到这两个目标。

这里是我的XML:

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

    <FrameLayout 
     android:id="@+id/AAA" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </FrameLayout> 

    <LinearLayout 
     android:id="@+id/BBB" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/AAA" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:id="@+id/list_container" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="1" > 

      <ListView 
       android:id="@+id/list" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:entries="@array/list_items"/> 
     </LinearLayout> 

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

      <Button 
       android:id="@+id/button1" 
       android:layout_above="@+id/bottom_layout" 
       android:layout_width="100dip" 
       android:layout_height="50dip" 
       android:clickable="true" 
       android:text="Button1" /> 

      <EditText 
       android:id="@+id/edittext" 
       android:layout_above="@+id/bottom_layout" 
       android:layout_toRightOf="@+id/button1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:minHeight="50dip" 
       android:imeOptions="flagNoExtractUi" 
       android:inputType="textMultiLine" 
       android:maxLines="8" 
       android:scrollbars="vertical" /> 

      <!-- Align this with the bottom so when the input text area gets 
       really big it doesn't push this section off screen --> 
      <LinearLayout 
       android:id="@+id/bottom_layout" 
       android:layout_alignParentBottom="true" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" > 

       <Button 
        android:id="@+id/button2" 
        android:layout_width="match_parent" 
        android:layout_height="150dip" 
        android:layout_gravity="bottom" 
        android:clickable="true" 
        android:text="Button2" /> 

      </LinearLayout> 

     </RelativeLayout> 

    </LinearLayout> 

</RelativeLayout> 

如果我从bottom_layout然后ListView的内容出现删除android:layout_alignParentBottom="true",但后来我输了,我想用的EditText的效果。

任何人都可以帮忙吗?我需要支持OS 2.2+。

回答

1

简化的布局有点像这样:

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

    <FrameLayout 
      android:id="@+id/AAA" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 
    </FrameLayout> 

    <RelativeLayout 
      android:id="@+id/BBB" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/AAA" 
      android:orientation="vertical" > 

      <ListView 
        android:id="@+id/list" 
        android:layout_above="@+id/edittext" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:entries="@array/list_items"/> 

      <Button 
        android:id="@+id/button1" 
        android:layout_above="@+id/bottom_layout" 
        android:layout_width="100dip" 
        android:layout_height="50dip" 
        android:clickable="true" 
        android:text="Button1" /> 

      <EditText 
        android:id="@+id/edittext" 
        android:layout_above="@+id/bottom_layout" 
        android:layout_toRightOf="@+id/button1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:minHeight="50dip" 
        android:imeOptions="flagNoExtractUi" 
        android:inputType="textMultiLine" 
        android:maxLines="8" 
        android:scrollbars="vertical" /> 

      <!-- Align this with the bottom so when the input text area gets 
       really big it doesn't push this section off screen --> 
      <LinearLayout 
        android:id="@+id/bottom_layout" 
        android:layout_alignParentBottom="true" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" > 

       <Button 
         android:id="@+id/button2" 
         android:layout_width="match_parent" 
         android:layout_height="150dip" 
         android:layout_gravity="bottom" 
         android:clickable="true" 
         android:text="Button2" /> 
      </LinearLayout> 

    </RelativeLayout> 

</RelativeLayout> 

似乎给你描述的结果。

Result

+0

谢谢,就是这样!我确定我尝试设置ListView在一个点上使用match_parent,所以现在我将尝试将这些结果合并回原始布局中... – 2013-05-14 03:52:00