4

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?

  • You should look into hyphenation, there is more information in this SO link: http://stackoverflow.com/questions/4454911/hyphenation-in-android – Marcel50506 Aug 25 '16 at 11:22

2 Answers2

1

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"/>
nobalG
  • 4,544
  • 3
  • 34
  • 72
1

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.
Uma Kanth
  • 5,659
  • 2
  • 20
  • 41