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.
You have to use CSS. Go with the <span> tag, or a separate style sheet. According to its specification, the <span> tag has no semantic meaning and just allows you to change the style of a particular region.
The <span> tag is an inline container used to mark up a part of a text, or a part of a document. The <span> tag is easily styled by CSS or manipulated with JavaScript using the class or id attribute. The <span> tag is much like the <div> element, but <div> is a block-level element and <span> is an inline element.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With