Search code examples
androidkotlinspanned

Spanned CSS style/color


Is there any way to use spanned colors directly from a string without using any Java/Kotlin code?
For example to bold text I can use "<b> $someString </b>"
But what is the way to change color? I searched it in Android Documentation and I found this.

CSS style: <span style=”color|background_color|text-decoration”>

But I don't get it how to set it, I tried to do it in many ways e.g.
"<span style=#999999|#999999|#999999> $someString </span>"
But it didn't work.


Solution

  • The character | means or.

    In the documentation you see <span style=”color|background_color|text-decoration”>

    Which means it can be any of <span style="color:#999999"> $someString </span>

    Or <span style="background-color:#999999"> $someString </span>

    Or <span style="text-decoration:underline"> $someString </span>