Function

withStyle

Pushes style to the AnnotatedString.Builder, executes block and then pops the style.

AnnotatedStringBuilderWithStyleSample

fun AnnotatedStringBuilderWithStyleSample() {
    buildAnnotatedString {
        withStyle(SpanStyle(color = Color.Green)) {
            // green text style will be applied to all text in this block
            append("Hello")
        }
        toAnnotatedString()
    }
}

Last updated: