我想把一个ListView
放在我的活动的顶部,而底部的东西没有ListView
“吞下”底部的小部件?我试过这个(“别的东西”是一个RelativeLayout
,只有一个按钮),但它不起作用。如何在Android中定位ListView?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
</ListView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button" />
</RelativeLayout>
</LinearLayout>
我找了一些提示here,这是非常有用的,但并没有说明ListView
什么事。我可以毫无问题地将零件放在ListView
以上,但不能低于。
现在列表并没有吞下按钮,但如果列表比可用空间短,它将直接显示在按钮上方而不是顶部。是否有可能使列表出现在顶部,但仍不能吞下按钮? – petersohn
@petersohn - 将ListView的高度设置为match_parent – dymmeh