team of professionals working hard to provid" /> team of professionals working hard to provid" /> team of professionals working hard to provid"/>

HTML in Jetpack Compose Text

4.4k Views Asked by At

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.

0

There are 0 best solutions below