Word out of space on one line

I have a TextView with a large font, and if I have a long word, then only the last char is placed on the next line. For instance:

Zusammenarbei

t

Now I would like to format the text like this:

Zusammenarb -

t

Is there any way to achieve this?

+4
source share
2 answers

I think better than doing a carryover, you can do something better. Consider the following image.

enter image description here

I think green will be very suitable for your need. Just declare textviewas follows:

 <TextView
            android:id="@+id/yourUniqueID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:ellipsize="end"  <!--THIS WILL DO FOR YOU-->
            android:maxLines="1"
            android:text="test"/>
+1
source

Look at the break strategy of TextView

android:breakStrategy="high_quality"

constant      value               description
high_quality    1   Line breaking uses high-quality strategy, including hyphenation.
+1
source

Source: https://habr.com/ru/post/1652449/


All Articles