Max Gierlachowski
Max Gierlachowski

Reputation: 446

Word has not enough space in single line

I have an TextView with a big fontsize and if I have a long word only the last char is put into the next line. For example :

Zusammenarbei

t

Now I would like to format the text to look like this:

Zusammenarb -

t

Is there a possibility to achive this?

Upvotes: 5

Views: 849

Answers (2)

Uma Kanth
Uma Kanth

Reputation: 5629

Look at the break strategy of the TextView

android:breakStrategy="high_quality"

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

Upvotes: 1

nobalG
nobalG

Reputation: 4620

I guess better than doing Hyphenation, you can do something better.Consider the following image.

enter image description here

I guess green one will be much suitable for your need. Just declare your textview as 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"/>

Upvotes: 1

Related Questions