16

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?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
TeeTracker
  • 7,064
  • 8
  • 40
  • 46

3 Answers3

34

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)
)
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
4

I did it like this.

 Text(text = "Hello",
        style = MaterialTheme.typography.h5.copy(
            lineHeight = 35.sp,  // Here line height 
        ),
  )

Or simply you can use lineHeight

   Text(text = "Hello",
            lineHeight = 35.sp
      )

Caution: sp is case sensitive

AgentP
  • 6,261
  • 2
  • 31
  • 52
1

Hi try to change style property of TextView - TextStyle.lineHeight