1

In my activity i hava a ListView which has an ArrayAdapter as its adapter, and is updated dynamically. I am using RelativeLayout. At first, the ListView is empty, but I can see that it takes up space on the screen compared to before i added it. As soon as one element is added, it is expanded and shows this element. As soon as I add a second element, I only see the top of the second element and then it goes behind the message text element under. How can I solve this?

<Button
    android:id="@+id/btnAddAttachment"
    android:layout_marginTop="7dp"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:layout_below="@id/sprType"
    android:text="Add attachment"/>

<!--ATTACHMENTS LIST-->
<ListView
    android:id="@+id/lstAttachments"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/btnAddAttachment">
</ListView>

<!-- MESSAGE TEXT -->
<EditText
    android:id="@+id/txtMessage"
    android:layout_width="fill_parent"
    android:layout_height="150dp"
    android:layout_below="@id/lstAttachments"
    android:layout_marginTop="7dp"
    android:lines="10"
    android:maxLines="10"
    android:maxLength="500"
    android:hint="Message text"
    android:gravity="top|left"/>   

1 Answers1

0

What is the android:layout_height value of the RelativeLayout?

Try changing the ListView to have:

android:layout_height="fill_parent"

and do the same for the RelativeLayout that contains it.

You can then align the EditText below it to the bottom of the ListView, and make sure the list view is layout_above that EditText

biddulph.r
  • 5,226
  • 3
  • 32
  • 47
  • If you align the ListView to be layout_above the EditText, and the EditText to be below the ListView, I would get a circular reference. Did I understand you correctly? – Aleksander Sjåfjell Oct 23 '12 at 08:17