1
<TextView
        android:layout_marginLeft="12dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/tvVExample"
        android:textColor="#496933"
        android:singleLine="false"
        android:textStyle="bold"
        android:textSize="16sp"/>

例如,文本是:

Having desirable or positive qualities especially those suitable for a thing specified

它向我展示了:

Having desirable or positive qualities especially those suita
specified

它可以包裹。它显示了两行但隐藏了一些单词

我的预期是:

Having desirable or positive qualities especially those 
suitable for a thing specified

4

2 回答 2

3

最后我找到了解决方案,如果 TextView 是 GridLayout 的子项。我无法将宽度设置为 WRAP_CONTECT 因为它将使用整行作为宽度,而不是单元格的宽度。解决方案是将宽度设置为 0dp 并将 layout_gravity 设置为 fill_horizo​​ntal。此外,gridlayout 的宽度必须是 MATCH_PARENT。

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:columnCount="3"
            android:orientation="horizontal">
.
.
.

<TextView
    android:layout_marginLeft="12dp"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_horizontal"
    android:text="New Text"
    android:id="@+id/tvVExample"
    android:textColor="#496933"
    android:textStyle="bold"
    android:textSize="16sp"/>
.
.
.
</GridLayout>
于 2013-06-08T08:41:51.277 回答
2

在许多情况下,诀窍似乎不是设置,single="false"但是maxLines="100",也许您可​​以尝试一下:

<TextView
    android:layout_marginLeft="12dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/tvVExample"
    android:textColor="#496933"
    android:maxLines="100"
    android:textStyle="bold"
    android:textSize="16sp"/>

如果您使用的是 LinearLayout 并且以上版本不起作用,您可以尝试添加android:layout_weight="1"(但layout_width必须设置为match_parent)。

于 2013-06-08T03:35:15.550 回答