Created
June 27, 2023 17:34
-
-
Save Abhimanyu14/6f09328c721e045b2e4af27bc61245bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ScrollingTextWithMaxLinesDemo() { | |
val textMeasurer = rememberTextMeasurer() | |
val density = LocalDensity.current | |
val textHeight = with(density) { | |
textMeasurer.measure( | |
text = randomText, | |
maxLines = 10, | |
style = TextStyle(), | |
).size.height.toDp() | |
} | |
Text( | |
text = randomText, | |
modifier = Modifier | |
.height(textHeight) | |
.verticalScroll(rememberScrollState()) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment