How to wrap text in textview in Android

前端 未结 18 1115
旧巷少年郎
旧巷少年郎 2020-12-08 18:03

Does any one know how to wrap text in TextView in Android platform. i.e if the text in textview exceed the screen length it should be displayed in the second line.

I

18条回答
  •  伪装坚强ぢ
    2020-12-08 18:49

    Constraint Layout

    
    
    • Ensure your layout width is zero
    • left / right constraints are defined
    • layout height of wrap_content allows expansion up/down.
    • Set android:maxLines="2" to prevent vertical expansion (2 is just an e.g.)
    • Ellipses are prob. a good idea with max lines android:ellipsize="end"

    0dp width allows left/right constraints to determine how wide your widget is.

    Setting left/right constraints sets the actual width of your widget, within which your text will wrap.

    Constraint Layout docs

提交回复
热议问题