https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
m

Mario Javier Medina Cocom

10/24/2023, 6:15 PM
Hello, can someone be kind enough to show me how to put different colored words in a text field, im using BasicTextField, please, ill really appreciate. i was trying to find annotated string but i could find that option
1
l

lazt omen

10/24/2023, 7:53 PM
Copy code
BasicTextField(colorFieldValue, {
            colorFieldValue = it.copy(
                annotatedString = buildAnnotatedString {
                    for (i in 0 until it.text.length step 5) {
                        withStyle(
                            style = SpanStyle(
                                color = Color(
                                    i*255 +  2.0.pow(31.0).toInt()
                                )
                            )
                        ) {
                            append(it.text.substring(i).take(5))
                        }
                    }
                }
            )
        })
m

Mario Javier Medina Cocom

10/24/2023, 8:00 PM
thank you!! , i solved using visualTransformation
2 Views