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 have searched and tried the following:
android:scrollHorizontally="false", android:inputType="textMultiLine", android:singleLine="false"
But none work..
Can anyone suggest how can I do it.
“how to wrap code in android studio” Code Answer "File->Settings->Editor->General" tab and check "Use soft wraps in editor".
Android Ellipsize Android TextView ellipsize property Causes words in the text that are longer than the view's width to be ellipsized ( means to shorten text using an ellipsis, i.e. three dots …) instead of broken in the middle to fit it inside the given view.
<TextView android:id="@+id/some_textview" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintLeft_toLeftOf="@id/textview_above" app:layout_constraintRight_toLeftOf="@id/button_to_right"/>
android:maxLines="2"
to prevent vertical expansion (2 is just an e.g.)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
For me this issue only occurred on Android < 4.0
The combination of parameters I used were:
android:layout_weight="1" android:ellipsize="none" android:maxLines="100" android:scrollHorizontally="false"
The maxLines count seemed to be the random final piece that made my TextView wrap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With