0
我必須做一個佈局,在第一行我有一個標題,在它下面,有ListView。標題應該左對齊,並且列表視圖應該與總寬度匹配。爲此,我使用以下xml。Android桌面佈局寬度概率
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splashContent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#7A0225"
android:orientation="vertical" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:layout_weight="0"
android:background="@drawable/search_bg_row1">
<TextView
android:id="@+id/pcomparetitle"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingBottom="4dp"
android:paddingLeft="10dip"
android:paddingRight="0dip"
android:paddingTop="10dp"
android:text="Price Comparison for ISBN: "
android:textColor="#FFFFFF"
android:background="#00FF00"
android:textSize="15sp"
android:textStyle="bold" >
</TextView>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:background="@drawable/search_bg_row3">
<ListView
android:id="@+id/pricelist"
android:background="#FF0000"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</TableRow>
</TableLayout>
現在,Listview的寬度與標題相同。由於標題與較高分辨率顯示的寬度相比較短,所以列表視圖取部分寬度。如何解決這個問題呢?
如果你只是想設置一個標題爲您的ListView,有'addHeaderView'方法:HTTP:/ /stackoverflow.com/questions/2620177/android-adding-static-header-to-the-top-of-a-listactivity – Dalmas 2011-12-20 13:18:54