Todor Grudev
09/07/2023, 10:16 AMHtmlText
the prime responsibility of which is to render a text that has some link in it returned from an API, while this seemed to worked for API < 34, it is not the case for the latter
@Composable
fun HtmlText(text: String, modifier: Modifier = Modifier) {
AndroidView(
modifier = modifier,
factory = {
TextView(it).apply {
autoLinkMask = Linkify.WEB_URLS
linksClickable = true
setLinkTextColor(Color.Blue.toArgb())
}
},
update = {
it.text = HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_COMPACT)
it.movementMethod = LinkMovementMethod.getInstance()
}
)
}
Anyone facing the same problem and how did you solve it?