How to wrap text to next line in an Android TextVi

2019-02-11 12:32发布

I am using following TextView to display some data in it:

<TextView android:id="@+id/notificationText" 
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:textSize="18sp"
        android:inputType="textMultiLine"
        android:maxLines="2"
        android:layout_paddingRight="20dip"
        android:textColor="#ffffff"/>

I want to wrap text to next line. How can I do this?

4条回答
手持菜刀,她持情操
2楼-- · 2019-02-11 12:42

You need to set

 android:minLines="2"
查看更多
你好瞎i
3楼-- · 2019-02-11 12:43

In Some case It works by setting width to 0dp on text views.

android:layout_width="0dp"

here is a link to original answer.

查看更多
淡お忘
4楼-- · 2019-02-11 12:50

You could also try

android:inputType="textMultiLine"

in your XML. This worked for me.

查看更多
爷的心禁止访问
5楼-- · 2019-02-11 13:01

you must set android:scrollHorizontally="false" in your xml.

查看更多
登录 后发表回答