JetPack中的HTML撰写文本

发布于 2025-02-10 05:37:49 字数 1152 浏览 1 评论 0原文

我试图启用html字符串,尤其是使用链接:

"We are a <a href="/about/about_team.htm">team</a> of professionals working hard to provide free learning content."

我用它来解释在这里,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 akram hussain > androidx.compose.material.textkt.kt 文本。不幸的是,该文本已显示,但是没有突出显示链接,链接根本不起作用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文