【问题标题】:how to display image from <img src> html tags from api?如何显示来自 api 的 <img src> html 标签的图像?
【发布时间】:2019-12-24 21:26:41
【问题描述】:

我用过holder.txtTitle.setText(HtmlCompat.fromHtml(dataList.getDescription(), 0));

HtmlCompat.fromHtml 移除标签但不显示图片

I'm getting something like this

如何显示整个图像而不是框?因为 HtmlCompat.fromHtml 不起作用。

提前致谢

HTML 文本(来自 API):

 <p>Android is a Linux based operating system it is designed primarily for touch screen mobile devices such as smart phones and tablet computers. The operating system have developed a lot in last 15 years starting from black and white phones to recent smart phones or mini computers. One of the most widely used mobile OS &nbsp; these days is android. &nbsp;The android is software that was founded in Palo Alto of California in 2003.</p>

<p><img alt="" src="http://mapi.trycatchtech.com/uploads/android_tutorials/bf029f4a311b3168e0cfda1a0ef78815.png" style="height:342px; width:500px" /></p>

<p>The android is a powerful operating system and it supports large number of applications in Smartphones. These applications are more comfortable and advanced for the users. The hardware that supports android software is based on ARM architecture platform. The android is an open source operating system means that it&rsquo;s free and any one can use it. The android has got millions of apps available that can help you managing your life one or other way and it is available low cost in market at that reasons android is very popular.</p>

<p><img alt="" src="http://mapi.trycatchtech.com/uploads/android_tutorials/666b3ec86e308cd3e7f6bb1d12bb06f2.png" style="height:316px; width:508px" /></p>

<p>The android development supports with the full java programming language. Even other packages that are API and JSE are not supported. The first version 1.0 of android development kit (SDK) was released in 2008 and latest updated version is jelly bean.</p>

【问题讨论】:

    标签: android retrofit retrofit2


    【解决方案1】:

    您无法在TextView 中加载 html 图像。让它WebView。然后加载像holder.webview.loadDataWithBaseURL(null,dataList.getDescription(),"text/html","UTF-8","about:blank");这样的html文本

    【讨论】:

    • 活动变成空白?没有加载?问题是什么……为什么它变成空白?
    • 你能在这里分享你的html文本吗?
    • hello shafayat ...我已经添加了html api text..看看
    • 嘿,它起作用了..而不是卡片视图。我使用了相对布局...非常感谢 shafayat ...我稍后会问更多问题..
    • 图片显示太大...我需要向右滚动才能查看完整图片...有没有办法将其最小化?
    【解决方案2】:

    你应该在 webView 的 rest api 响应中使用 html val htmlText="your html" webview.loadUrl("file:///android_asset/abc.html");

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-29
      • 2016-11-22
      • 2019-11-27
      • 2016-10-22
      • 2021-10-16
      • 2014-09-29
      • 1970-01-01
      相关资源
      最近更新 更多