Reputation: 25673
Here's a simplified version of the portrait UI I want from my layout:
It's a ListView above another layout.
The complication is that I want the whole bottom layout (in this case 'Button2') to be visible when lots of lines get added to the EditText:
I've been trying to achieve this by nesting a RelativeLayout inside a LinearLayout. Unfortunately, the ListView disappears when I get the effect I want with the EditText, e.g.
I've tried loads of alternatives, but nothing seems to achieve both goals.
Here's my 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>
If I remove the android:layout_alignParentBottom="true"
from the bottom_layout then the ListView contents appears, but then I lose the effect I want with the EditText.
Can anybody help? I need to support OS 2.2+.
Upvotes: 0
Views: 718
Reputation: 11073
Simplifying the layout a bit like this:
<?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>
seems to give the result you were describing.
Upvotes: 1