mattinger
12/14/2022, 6:12 PM@Composable
@Preview
fun TestParagraph() {
val density = LocalDensity.current
val fontFamilyResolver = LocalFontFamilyResolver.current
val placeholderText = "H".repeat(10)
val paragraph1 = Paragraph(
text = placeholderText,
style = MaterialTheme.typography.body1,
spanStyles = listOf(),
maxLines = 1,
ellipsis = false,
density = density,
fontFamilyResolver = fontFamilyResolver,
constraints = Constraints()
)
val paragraph2 = Paragraph(
text = (1.. 2).map { placeholderText }.joinToString("\n"),
style = MaterialTheme.typography.body1,
spanStyles = listOf(),
maxLines = 2,
ellipsis = false,
density = density,
fontFamilyResolver = fontFamilyResolver,
constraints = Constraints()
)
val height1 = paragraph1.height
val height2 = paragraph2.height
Column {
Text(text = "${height1}")
Text(text = "${height2}")
}
}
mattinger
12/14/2022, 6:13 PMmattinger
12/14/2022, 6:32 PMKirill Grouchnikov
12/14/2022, 7:11 PMmattinger
12/14/2022, 11:29 PMmattinger
12/14/2022, 11:30 PMKirill Grouchnikov
12/14/2022, 11:30 PMmattinger
12/14/2022, 11:31 PMmattinger
12/14/2022, 11:32 PMAlbert Chang
12/15/2022, 5:00 AMmattinger
12/17/2022, 4:42 AM