7

I have added soft hyphen signs to all of my strings, yet android breaks the lines at entirely different points. Is there a way to breack the lines only at the points with either a soft hyphen or a space?

Please note that I want to target API 21 and above, so using breakStrategy or hyphenation frequency is not a solution.

None of these questions/answers worked for me: Hyphenation in Android

Android:- How to add Hyphen "-" in word break android TextView below 6.0 OS

How to force hyphenation in TextView? (character "-" on word split)

Koushik Mondal
  • 865
  • 7
  • 15
BraveSentry
  • 339
  • 4
  • 19

3 Answers3

2

Try to add android:hyphenationFrequency="normal" to your textview

Douaa Su
  • 51
  • 4
1

To make it working use soft hyphen \u00AD in strings, e.g.:

<string name="einzelfahrt_name">Einzelfahrrad\u00ADkarte</string>

and in your TextView add:

android:hyphenationFrequency="full"
APTower
  • 343
  • 2
  • 8
0

You can use \n to break your string. Try this way.

<string name="your_string_name">I want to break after this\nIt's working fine</string>
Koushik Mondal
  • 865
  • 7
  • 15
  • 4
    Thanks, but theres one problem: Depending on screen size, the line will break at different points. If I put `\n` on all those places, I´ll have too many breaks. I´m looking for a way to say "If you break the line, break it only at the points where there is a (soft) hyphen." – BraveSentry May 29 '19 at 14:09