There is yet no official Composable to do this. For now i’m using an AndroidView with a TextView inside. Not the best solution, but it’s simple and that solves the problem.
@Composable
fun HtmlText(html: String, modifier: Modifier = Modifier) {
AndroidView(
modifier = modifier,
factory = { context -> TextView(context) },
update = { it.text = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_COMPACT) }
)
}
If you have tags in the HTML you need to set the TextView
property movementMethod = LinkMovementMethod.getInstance()
to make the links clickable.