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"/>   
4

1 回答 1

0

android:layout_height价值是RelativeLayout什么?

尝试将 更改ListView为:

android:layout_height="fill_parent"

并对RelativeLayout包含它的内容执行相同的操作。

然后,您可以将其EditText下方与底部对齐ListView,并确保列表视图layout_aboveEditText

于 2012-10-22T15:18:28.097 回答