I tried to enable HTML strings, especially with links e.g.:
"We are a <a href="/about/about_team.htm">team</a> of professionals working hard to provide free learning content."
I used it like explained here by Akram Hussain:
val body = "We are a <a href="www.link.com/about/">team</a> of professionals working hard to provide free learning content."
val text = HtmlCompat.fromHtml(body, Html.FROM_HTML_MODE_LEGACY)
// HtmlCompat.fromHtml(description, HtmlCompat.FROM_HTML_MODE_LEGACY)
Text(
text = text.toString(),
style = myStyle,
overflow = TextOverflow.Ellipsis,
maxLines = 4,
modifier = Modifier
.clickable(
enabled = true,
onClick = { },
indication = rememberRipple(bounded = true),
interactionSource = MutableInteractionSource(),
)
.animateContentSize(animationSpec = spring()),
onTextLayout = {
//
}
)
in a androidx.compose.material.TextKt.kt
Text. Unfortunately, the text is shown, but no link is highlighted and link is not working at all.
val startIndex = str.indexOf("link")
. I do not want to change the code (for annotedstring), prefferable it should work for all HTML out of the box. So I was looking for a solution with HTML tag like a and href, so that I do not have to use AnnotatedString anymore. – ExarchateAndroidView
as shown in this answer? I think there's no built-in way in Compose so far – Frondescence