2011-03-16 173 views
2

我有一個ListActivity,它使用以下xml爲每個項目填充列表視圖。RelativeLayout - TextView不顯示

任何人都可以請告訴我爲什麼第三行的時間窗口的名稱不顯示?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="100dip" 
android:padding="6dip" android:id="@+id/result_item" android:background="#000000"> 

<TextView android:id="@+id/rule" android:layout_marginLeft="55dip" 
    android:layout_width="fill_parent" android:layout_height="26dip" 
    android:layout_toRightOf="@+id/imgview" android:textAppearance="?android:attr/textAppearanceMedium" 
    android:gravity="bottom" android:text="Rule....." /> 

<TextView android:id="@+id/accuracy" android:layout_width="fill_parent" 
    android:layout_height="26dip" android:layout_below="@+id/rule" 
    android:layout_alignLeft="@id/rule" android:layout_alignParentBottom="true" 
    android:gravity="top" android:text="Accuracy" /> 

<TextView android:id="@+id/time_window" android:layout_width="fill_parent" 
    android:layout_height="26dip" android:layout_below="@+id/accuracy" 
    android:layout_alignLeft="@id/rule" android:layout_alignParentBottom="true" 
    android:gravity="top" android:text="time window..." /> 

<ImageView android:id="@+id/imgmine" android:layout_width="38px" 
    android:layout_height="38px" android:layout_gravity="center_vertical" 
    android:src="@drawable/mine" /> 
     </RelativeLayout> 

回答

4

第二個視圖是取所有的高度空間:android:layout_alignParentBottom="true"。刪除該語句,它將解決問題。

順便說一下,強烈建議您也使用Android SDK中的hierarchyviewer。它允許您查看視圖的構建方式並檢測這種錯誤。

+0

so alignParentBottom只能用於最後一個視圖?如果是這種情況,那麼它解決了我的問題:-)乾杯! – kkudi 2011-03-16 15:49:32