1

I'm working right now with AnnotedStrings to create this Text with two different text styles: Image with alabel displaying 1.26 Kilowatts text

I'm setup this text using a SpanStyle. How do I setup the line height this way? In the SpanStyle is missing this attribute.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Felipe Castilhos
  • 766
  • 1
  • 8
  • 18

1 Answers1

4

You can use the ParagraphStyle to define the lineHeight and the lineHeightStyle.

Something like:

buildAnnotatedString {
    withStyle(style = ParagraphStyle(lineHeight = 60.sp)) {
        withStyle(style = SpanStyle(color = Color.Blue, fontSize= 60.sp)) {
            append("Hello")
        }
        append("Compose")
    }
}

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841