1
在我的活动中,我有一个ListView,它有一个ArrayAdapter作为它的适配器,并被动态更新。我正在使用RelativeLayout。起初,ListView是空的,但是我可以看到它比起我添加之前占用了屏幕上的空间。只要添加了一个元素,它就会展开并显示该元素。只要我添加第二个元素,我只能看到第二个元素的顶部,然后它就会在下面的消息文本元素后面。我该如何解决这个问题?向ListView添加元素使用RelativeLayout将其扩展到其他元素下面
<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"/>
如果对齐的ListView是layout_above的EditText上,和EditText上,以低于ListView,我会得到一个循环引用。我对你有正确的理解吗? –