自定義標題欄我有一個活動擴展ListActivity 我想添加的LinearLayout或RelativeLayout的就行了 像動作遊戲 的頂部,但是當我在XML中添加 列表不顯示,爲什麼?與ListView的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="1111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"/>
</RelativeLayout>
<ListView android:id="@id/android:list" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"
android:drawSelectorOnTop="false" android:padding="4dip" />
<TextView android:id="@id/android:empty" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="No_data" />
</LinearLayout>
沒有什麼能阻止他在這裏使用ListActivity,佈局錯誤並且不會爲ListView留出空間。 – adamp 2011-03-08 17:03:48
感謝糾正adamp :) – 2011-03-08 17:52:39
沒問題。 :)這是一個相當普遍的問題,這就是爲什麼我們在幾個版本之前將「fill_parent」的名稱更改爲「match_parent」。 「fill_parent」意味着一個類似於layout_weight的行爲,其中很多人會在後面的元素中共享空間,但這實際上意味着「在這個方向上佔用剩下的可用空間」。一旦LinearLayout中的match_parent項的方向相同,所有後續子項的寬度或高度都將爲0,因爲沒有剩餘空間給它們。 – adamp 2011-03-08 21:34:24