我已經在2.2中使用了這個,不知道layout_above和layout_below標籤是否可用1.5(如果這是你使用的)。 佈置您要填充剩餘區域的三個主要元素,頁眉,頁腳和中心內容(在本例中爲列表視圖)。
如果需要,您可以用ListView替換ListView或任何組件。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Top Button"/>
<Button
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button"/>
<ListView
android:id="@android:id/center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/header"
android:layout_above="@id/footer"/>
</RelativeLayout>
請注意您的元素的順序。不確定它的相關性,但中心元素是最後定義的。