Home > OS >  Jetpack Compose Text Hyphenation
Jetpack Compose Text Hyphenation

Time:10-20

How do I get words to break correctly to new lines in Android with Jetpack Compose? I know the functionality from the web, where I use ­ for such cases.

I defined string values with possible line breaks like this: Korrespondenz\u00ADsprache. Unfortunately this does not work for Android.

I use the following code

Text(
    text = "Korrespondenz\u00ADsprache",
    style = MaterialTheme.typography.h4
)

Currently the result looks like this:

enter image description here

The expected result should look like this:

enter image description here

CodePudding user response:

Looks like hyphen is just recently supported in Compose 1.3.0-rc01 release candidate as part of Experimental API

enter image description here

With Auto the words will be automatically broken at appropriate hyphenation points.

It requires 1.3.0-rc01

  • Related