Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set line-space with Android Jetpack Compose Text()?

I want to give more space dp between lines in the Text() content. The only property I find is the letterSpacing of TextStyle, however, it doesn't seem as I want, can we set it with composing somehow?

like image 620
TeeTracker Avatar asked Sep 09 '25 17:09

TeeTracker


1 Answers

You can use the lineHeight property:

Text(text = "Hello Compose".repeat(50),
    modifier = Modifier.padding(10.dp).width(200.dp),
    maxLines = 5,
    lineHeight = 50.sp
)

With 20.sp and 50.sp

enter image description here enter image description here

or you can use the TextStyle:

Text(text = "Hello Compose".repeat(50),
    modifier = Modifier.padding(10.dp).width(200.dp),
    maxLines = 5,
    style = LocalTextStyle.current.copy(lineHeight = 50.sp)
)
like image 192
Gabriele Mariotti Avatar answered Sep 13 '25 07:09

Gabriele Mariotti