让TextView包装

时间:2012-08-22 06:18:17

标签: android textview word-wrap

我知道这个问题已被多次询问,但我似乎仍无法让这个问题起作用。 我尝试过各种各样的组合,它只是拒绝换行。

现在就是这样:

    <TextView
        android:id="@+id/doctor_details_clinic_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingRight="3dip"
        android:textSize="12sp"
        android:maxLines="1"
        android:layout_gravity="right"
        android:gravity="right"
        android:scrollHorizontally="false"
        android:singleLine="false"
        android:ellipsize="none"
        />

我已经尝试过宽度为0dip以及所有其他建议,但是不合适。

1 个答案:

答案 0 :(得分:1)

首先,您应将Max lines设置为2而不是1。 这样的事情会起作用:

    <TextView
        android:id="@+id/myText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:maxLines="2"
        android:ellipsize="end"
        android:text="this is the most interesting use of text view I have seen so far,this is the most interesting use of text view I have ever seen so far,this is the most interesting use of text view I have ever seen so far this is the most interesting use of text view I have ever seen so far"/>