2013-04-09 46 views
0

如标题所示,我有一个列表视图,行中包含多行的textview。 由于它有多条线,它的行为就像图片展示一样。Android - 列表视图中包含多行textview的行

基本上它应该只显示第一行,但是会发生的是下面的行正在推高。 这只发生在冰淇淋三明治和果冻豆。在姜面包看起来不错。

pic

下面是该行的XML代码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/main_list_row" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" > 
     <TextView 
      android:focusableInTouchMode="false" 
      android:clickable="false" 
      android:focusable="false" 
      android:id="@+id/item_yyyy" 
      android:gravity="center" 
      android:textIsSelectable="true" 
      android:layout_width="0dp" 
      android:layout_height="23dp" 
      android:layout_weight=".14" 
      android:textSize="15sp" /> 
     <TextView 
      android:focusableInTouchMode="false" 
      android:clickable="false" 
      android:focusable="false" 
      android:id="@+id/item_dd" 
      android:gravity="center" 
      android:textIsSelectable="true" 
      android:layout_width="0dp" 
      android:layout_height="23dp" 
      android:layout_weight=".11" 
      android:textSize="15sp" /> 
     <TextView 
      android:focusableInTouchMode="false" 
      android:clickable="false" 
      android:focusable="false" 
      android:id="@+id/item_mm" 
      android:gravity="center" 
      android:textIsSelectable="true" 
      android:layout_width="0dp" 
      android:layout_height="23dp" 
      android:layout_weight=".11" 
      android:textSize="15sp" /> 
     <TextView 
      android:focusableInTouchMode="false" 
      android:clickable="false" 
      android:focusable="false" 
      android:id="@+id/item_state" 
      android:gravity="center" 
      android:textIsSelectable="true" 
      android:layout_width="0dp" 
      android:layout_height="23dp" 
      android:layout_weight=".13" 
      android:textSize="15sp" /> 
     <TextView 
      android:focusableInTouchMode="false" 
      android:clickable="false" 
      android:focusable="false" 
      android:id="@+id/item_pu" 
      android:gravity="center" 
      android:textIsSelectable="true" 
      android:layout_width="0dp" 
      android:layout_height="23dp" 
      android:layout_weight=".11" 
      android:textSize="15sp" /> 
     <TextView 
      android:focusableInTouchMode="false" 
      android:clickable="false" 
      android:focusable="false" 
      android:id="@+id/item_detailes" 
      android:paddingLeft="5dp" 
      android:textIsSelectable="true" 
      android:layout_width="0dp" 
      android:layout_height="23dp" 
      android:layout_weight=".40" 
      android:textSize="15sp" /> 
</LinearLayout> 

我试图与Android搞乱:在该行的XML,但没有结果填充。

我该怎么办? 谢谢。

回答

0

我用下面这行代码修复了它:android:singleLine =“true”。 现在它看起来不错:

enter image description here

1

enter image description here

尝试在你的布局添加android:weightSum

如果我的列表中有3列,然后在peren布局我添加android:weightSum="3"

,并在所有的孩子,我添加下面列表行文件的代码

android:layout_width="0dp" 
android:layout_height="wrap_content" 
android:layout_weight="1" 

检查:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:weightSum="3" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Large Text" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Large Text" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Large Text" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

</LinearLayout> 

如果你想使它成为中心,然后在perent线性布局中使用android:gravity="center"

0

如果在另一个地方,你有一个多行文本和相同的ISSU可以使用

android:layout_gravity="fill" 
相关问题