1

There are vertical paddings of Text Composable as you can see below

enter image description here

To remove vertical paddings of Text, I tried to modify my code, but not working.

            Text(
                text = "2",
                fontSize = 100.sp,
==================
Case 1.
                modifier = Modifier.padding(0.dp),      ## First thing I tried, but not working.

==================
Case 2.
                style = LocalTextStyle.current.merge(   ## Second, but also not working.
                    TextStyle(
                        fontSize = 100.sp,
                        // lineHeight = 2.5.em,
                        lineHeightStyle = LineHeightStyle(
                            alignment = LineHeightStyle.Alignment.Bottom,
                            trim = LineHeightStyle.Trim.LastLineBottom,
                        ),
                    ),
                )

            ) // The end of the Text()

Those cases are not working.

I want to remove paddings of that Text Composable, and result in having padding 0.

======Edited======

Also, I test in @Preview function

@Preview
@Composable
fun PreviewText100sp() {
    Text(
        "100",
        fontSize = 100.sp
    )
}

But, still it seems like Text() have vertical paddings like below.

enter image description here

Steve
  • 23
  • 5

1 Answers1

0

Use wrapContentSize(unbounded = true) to your text's Modifier

or you can use your custom line height as well, this way -

style = MaterialTheme.typography.titleSmall.copy(
    lineHeight = 14.sp,  // Here line height
)