2010-09-04 48 views
1

alt textTextView中的文本换行标签内

首先,关于大屏幕抱歉。我正在尝试让文字换行,但目前我无法做到。我已经尝试过android:layout_width =“fill_parent”,android:scrollHorizo​​ntal =“false”,android:width =“0dip”。有没有人有任何想法我可以实现文字环绕?下面是XML的一个样本:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent"> 

<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:stretchColumns="2"> 

    <TableRow> 

     <TextView 
      android:layout_column="1" 
      android:gravity="center" 
      android:background="@drawable/lgrayborder" 
      android:paddingRight="5dip" 
      android:paddingLeft="5dip" 
      android:id="@+id/chatUser1"/> 

     <TextView 
      android:layout_column="1" 
      android:gravity="left" 
      android:background="@drawable/lgrayborder" 
      android:paddingLeft="5dip" 
      android:id="@+id/chatComm1"/> 

    </TableRow> 

    <TableRow> 

     <TextView 
      android:layout_column="1" 
      android:gravity="center" 
      android:background="@drawable/lgrayborder" 
      android:paddingRight="5dip" 
      android:paddingLeft="5dip" 
      android:id="@+id/chatUser2"/> 

     <TextView 
      android:layout_column="1" 
      android:gravity="left" 
      android:background="@drawable/lgrayborder" 
      android:paddingLeft="5dip" 
      android:id="@+id/chatComm2"/> 

    </TableRow> 
</TableLayout> 
</ScrollView> 

更新:我已经尝试了,希望这将迫使TextViews包,但无济于事设置在滚动型,TableLayout和的TableRow属性。仍在寻找解决方案。

回答

3

你是否已经尝试过使用

android:maxEms="int" 

结合ellipsize?这应该可以解决你的问题。

+0

你先生,是一位<*explicit*>天才。谢谢。 – 2010-09-06 01:49:23

0

您需要设置TextViewellipsize属性。

+0

我想这三个机器人:ellipsize = “启动”,那么Android: singleLine =“false”,android:scrollHorizo​​ntally =“false”,他们都没有工作。另外,Ellipsize可以让单词在中间不会被破坏,但是并不能真正解决主要问题。 – 2010-09-04 07:25:21

+0

尝试singleLine =“true”和ellipsize =“end”。 HTH! – Karan 2010-09-04 08:26:20

+0

仍然没有解决它。我试过每一种组合...... – 2010-09-05 05:53:21

1

我有同样的问题与TableLayout,并通过设置柱收缩固定为 “真” 是这样的:

TableLayout tl = (TableLayout)findViewById(R.id.ViewTaskTable); 
tl.setColumnShrinkable(0, true); 

HTH