2013-07-08 52 views
0

所以我有一个使用ArrayAdapter等设置的自定义列表视图。我有这一切工作正常,但这是更多的关于设计的问题,我想。自定义列表视图 - 排列项目

我在每行有2个ListView,我希望边缘区域在每一行上排队,因为它在第一个TextView中有不同数量的字符。

下面是一个例子图片: enter image description here

你可以看到,在实施例1,2和3,不用排队,我想改变这使他们可以,但我无法弄清楚如何。我已经打了一些边缘,但这没有帮助。下面是该行的XML:

<?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" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/listViewRowItemInitials" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_marginBottom="10dp" 
     android:layout_marginLeft="15dp" 
     android:layout_marginRight="15dp" 
     android:layout_marginTop="10dp" 
     android:gravity="center_vertical" 
     android:textSize="12sp" /> 

    <TextView 
     android:id="@+id/listViewRowItemFull" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginBottom="10dp" 
     android:layout_marginTop="10dp" 
     android:gravity="center_vertical" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

</LinearLayout> 
+1

你可以给宽度“DP”为listViewRowItemInitials,也用“gravit”如果你想要的文字在其中左/右对齐。 –

回答

2

只要指定一个宽度为第一TextView

<TextView 
    android:id="@+id/listViewRowItemInitials" 
    android:layout_width="100dp" 
    android:layout_height="fill_parent" 
    android:layout_marginBottom="10dp" 
    android:layout_marginLeft="15dp" 
    android:layout_marginRight="15dp" 
    android:layout_marginTop="10dp" 
    android:gravity="center_vertical" 
    android:textSize="12sp" />