2012-04-30 168 views
1

我正在處理我的應用程序的設計,但是我對ListView的項目的設計有一些問題。ListView項目佈局

附加你可以找到它是怎樣的,以及我是如何想它的。

這是項的佈局:

<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="?android:attr/activatedBackgroundIndicator" 
android:minHeight="?android:attr/listPreferredItemHeight" > 

     <TextView android:id="@android:id/text1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft" 
      android:layout_marginTop="8dip" 
      android:textAppearance="?android:attr/textAppearanceListItem" 
     /> 


     <RelativeLayout android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentRight="true" > 

      <ImageView 
      android:id="@+id/favourite_status" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentRight="true" 
      android:layout_alignTop="@android:id/text1" 
      android:src="@drawable/is_not_favourite" 
      android:contentDescription="@string/list_favorites_status" 
      android:background="@null" 
      android:layout_margin="9dp"/> 

     </RelativeLayout> 

     <TextView android:id="@android:id/text2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@android:id/text1" 
      android:layout_alignLeft="@android:id/text1" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
     /> 



    </TwoLineListItem> 

的問題是全文:我不想描述中,應該是空的空間溢出。 在此先感謝您的幫助。

How it looks like

How it should be

+0

wrapContent'而不是給定值。 – thepoosh

+1

這只是正確構建佈局的問題。上面的佈局,你有一個文本視圖(你的標題),然後是一個相關佈局(你的圖像),然後基本漂浮在右邊,然後你的最終文本視圖(你的描述),只是吃剩下的所有空間。 – ASceresini

+0

感謝您的幫助。問題是我想留下星空下的空白,並且不讓文本溢出 – Gnufabio

回答

0

容易,你可以做到以下幾點:

<LinearLayout 
    .... 
    android:orientation="horizontal" 
    ....> 
    <LinearLayout 
     .... 
     android:orientation="vertical" 
     ....> 
     <TextView /> 
     <TextView /> 
    </LinearLayout> 
    <ImageView /> 
</LinearLayout> 

這是一個基本的佈局,你也可以達到同樣的用RelativeLayout的你正在使用`

+0

http://pastebin.com/UXgxfG9k仍然是相同的結果.. – Gnufabio

相關問題