can you elaborate your answer with a sample code of how to make that work?
a
annsofi
07/11/2024, 9:30 AM
There's a sample in the link:
Copy code
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.fromHtml
// First, download a string as a plain text using one of the resources' methods. At this stage
// you will be handling plurals and formatted strings in needed. Moreover, the string will be
// resolved with respect to the current locale and available translations.
val string = stringResource(id = R.string.example)
// Next, convert a string marked with HTML tags into AnnotatedString to be displayed by Text
val styledAnnotatedString = AnnotatedString.fromHtml(htmlString = string)
BasicText(styledAnnotatedString)
If you're not on the pre-release versions of Compose it looks like it might be used like this instead: