https://kotlinlang.org logo
#compose
Title
# compose
n

Napa Ram

11/23/2021, 9:45 AM
Hi Everyone, can anyone help me i am not able to figure out how we can add asterisk in red colour as per Screenshot
m

maciejciemiega

11/23/2021, 10:20 AM
I think that would work:
Copy code
val label = buildAnnotatedString {
    append("User Name")
    withStyle(SpanStyle(color = Color.Red)) {
        append(" *")
    }
}
1
c

Chris Sinco [G]

11/24/2021, 4:15 AM
Yep the above should work, but we sure to pass within a
Text
Composable into the
label
parameter which is a slot parameter:
Copy code
label = {
    Text(
        text = buildAnnotatedString {
            append("User Name")
            withStyle(SpanStyle(color = Color.Red)) {
                append(" *")
            }
        }
    )
},
n

Napa Ram

11/25/2021, 12:18 PM
Thanks @maciejciemiega @Chris Sinco [G]
👍 1