如何从api的<img src> html标签显示图像?

时间:2019-12-23 13:42:27

标签: android retrofit retrofit2

我用过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>

2 个答案:

答案 0 :(得分:2)

您无法在TextView中加载html图像。使其WebView。然后加载holder.webview.loadDataWithBaseURL(null,dataList.getDescription(),"text/html","UTF-8","about:blank");

这样的html文本

答案 1 :(得分:0)

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