开发者

Text wrap in TextView within a Tab

Text wrap in TextView within a Tab

First off, sorry about the large screen. I am trying to get the text to wrap but am currently unable to do so. I have tried android:layout_width="fill_parent", android:scrollHorizontal="false", android:width="0dip" all of which suggested in another question. Does anyone have any idea how I can achieve text wrapping? Here's a sample of the xml:

&开发者_JS百科lt;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>

Update: I have tried setting attributes in the ScrollView, TableLayout, and TableRow in hopes that it would force the TextViews to wrap but to no avail. Still looking for a solution to this.


Have you already tried to use

android:maxEms="int"

in combination with ellipsize? This should solve your problems.


I had the same issue with TableLayout and fixed it by setting column shrinkable to "true" like this:

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

HTH


You need to set the ellipsize property of the TextView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜