Created
November 8, 2022 09:14
-
-
Save cp-radhika-s/18d1b3cdd12fadc0d34d5d9fef924736 to your computer and use it in GitHub Desktop.
This file contains 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
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextLayoutResult() { | |
val textMeasure = rememberTextMeasurer() | |
var textLayoutResult by remember { mutableStateOf<TextLayoutResult?>(null) } | |
Canvas( | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(100.dp) | |
.layout { measurable, constraints -> | |
... | |
} | |
) { | |
drawRect(color = Color.Black) | |
textLayoutResult?.let { | |
drawText( | |
textLayoutResult = it, | |
alpha = 1f, | |
shadow = Shadow(color = Color.Red, offset = Offset(5f, 8f)), | |
textDecoration = TextDecoration.Underline | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment