Skip to content

Instantly share code, notes, and snippets.

@cp-radhika-s
Created November 8, 2022 09:13
Show Gist options
  • Save cp-radhika-s/e898fff05897592085c70c2647acfdab to your computer and use it in GitHub Desktop.
Save cp-radhika-s/e898fff05897592085c70c2647acfdab to your computer and use it in GitHub Desktop.
val textMeasure = rememberTextMeasurer()
var textLayoutResult by remember { mutableStateOf<TextLayoutResult?>(null) }
Canvas(
modifier = Modifier
.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
textLayoutResult = textMeasure.measure(
AnnotatedString("Text on Canvas!"),
style = TextStyle(
// text styling
)
)
layout(placeable.width, placeable.height) {
placeable.place(0, 0)
}
}
) { //draw }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment