2012-04-30 166 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

相关问题