Pablo
07/11/2024, 9:07 AMtext.parseAsHtml()
But it returns a Spannable and Text composable requires a Stringannsofi
07/11/2024, 9:11 AMPablo
07/11/2024, 9:25 AMannsofi
07/11/2024, 9:30 AMimport 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: "text with <b>markup</b>".parseAsHtml
That's based on these release notes: https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0-alpha07Pablo
07/11/2024, 9:33 AMPablo
07/11/2024, 9:33 AMsindrenm
07/11/2024, 9:48 AMmohamed rejeb
07/11/2024, 9:54 AMRichText
and RichTextEditor
composables and supports multiplatform.