V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
rcj6056
V2EX  ›  Android

请教个加载前端富文本的问题

  •  
  •   rcj6056 · Aug 25, 2025 · 3934 views
    This topic created in 249 days ago, the information mentioned may be changed or developed.

    这个图不知道能不能显示出来 https://imgur.com/a/8SSmyzQ

    接口返回了一个 content 字段 里面是 html 的标签 现在想在原生安卓里面直接加载出来 这种直接用 webview 可以加载嘛 或者有啥别的方案

    第一次遇到这种~

    8 replies    2025-08-26 14:29:25 +08:00
    bbxx11
        1
    bbxx11  
       Aug 25, 2025
    可以,富文本可以直接传图,存的就是标签+url ;自己配好图片上传地址,返回来也就直接渲染了
    irisdev
        2
    irisdev  
       Aug 25, 2025
    返回网络图片没问题,本地图片注意路径
    sankemao
        3
    sankemao  
       Aug 25, 2025
    textview 支持 html 部分标签,可以先试一下效果
    如果效果不行,就自己解析吧,把 html 解析成 ast ,然后自定义 span 显示
    SanjinGG
        4
    SanjinGG  
       Aug 25, 2025
    你直接保存 html ,能在本地加载出来就能在 webview 加载出来
    virgo
        5
    virgo  
       Aug 25, 2025
    https://github.com/andrejewski/himalaya 可以参考这个的方案解析一下再加载
    chf007
        6
    chf007  
       Aug 25, 2025
    loadDataWithBaseURL(null, htmlContent, "text/html", "utf-8", null)
    Lockroach
        7
    Lockroach  
       Aug 26, 2025
    使用 htmltextview 第三方组件或者将 webview 加载 html 内容
    rcj6056
        8
    rcj6056  
    OP
       Aug 26, 2025
    @chf007 牛的 xd 我就用这个处理好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2409 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 10:35 · PVG 18:35 · LAX 03:35 · JFK 06:35
    ♥ Do have faith in what you're doing.