2012-07-22 61 views
0

我想要一个列表视图,在我的应用程序中有header.xml和row.xml文件。 他们都是线性布局和6个孩子textview。 第一个textview是ID,我想将其最小化(仍然可见),因为它对用户不重要。如何水平地正确设置textview的layout_width和layout_weight?

码(header.xml):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:paddingBottom="6dip" 
    android:paddingTop="4dip" > 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:text="ID" 
     android:textSize="12dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Date" 
     android:textSize="12dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="time" 
     android:textSize="12dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Food" 
     android:textSize="12dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Rating2" 
     android:textSize="12dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Rating" 
     android:textSize="12dp" /> 

</LinearLayout> 

的问题是,现在的ID的TextView成为完全消失。我认为layout_weight越高,视图越小(在width = fill_parent的情况下)。 任何帮助表示赞赏。

回答

0
<TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:text="ID" 
     android:textSize="12dp" 
     android:visibility="invisible"/> 

所以加android:visibility="invisible"

相关问题