简体   繁体   中英

Is it possible to display complex HTML content inside TextView?

Is it possible to display complex HTML content inside TextView ? My HTML is going to have images and video tags. Is that possible or to use WebView component or there is some simpoler solution ?

If you want to use HTML tags for TextViews, you have to use android.text.Html class, fromHtml() ..

From Mark Murphy's Technical Stuff...

HTML Tags Supported By TextView

More importantly, it means that you cannot rely on what it will support from release to release.

* <a href="...">
* <b>
* <big>
* <blockquote>
* <br>
* <cite>
* <dfn>
* <div align="...">
* <em>
* <font size="..." color="..." face="...">
* <h1>
* <h2>
* <h3>
* <h4>
* <h5>
* <h6>
* <i>
* <img src="...">
* <p>
* <small>
* <strike>
* <strong>
* <sub>
* <sup>
* <tt>
* <u>

For more complex HTML tags you have to use WebView ...

最好的方法是将WebView用于复杂的HTML内容,仅在TextView使用HTML内容以使文本视图具有自定义样式

I would definitely use WebView instead of TextView. WebView is made for this exact task, so I cannot see why you would want to use TextView in the first place :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM