2013-05-14 69 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