Android中html.fromhtml的使用方法
16lz
2021-01-23
Android中html.fromhtml
在android中,有一个容易遗忘的Html.fromhtml方法,意思是可以将比如文本 框中的字符串进行HTML格式化,支持的还是很多的,
但要注意的是要在string.xml中用去转义,比如:
teletype-style font. But no use for the code
tag! ]]>
上面就用到了大量的HTML标签了,JAVA代码中这样使用:
TextView view = (TextView)findViewById(R.id.sampleText); String formattedText = getString(R.string.htmlFormattedText); Spanned result = Html.fromHtml(formattedText); view.setText(result);
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
更多相关文章
- Android滚动显示TXT中文文本
- Android TextView 中文本横向滚动效果实现
- Android UI系列:TextView显示文本
- Android 存储字符串数据到txt文件
- 【转载】Android绘图系列(五)——绘制文本
- android实现文本朗读,TextToSpeech