如何使XML字符串加粗,下划线等? [英] How to make XML strings bold, underlined etc?

查看:1577
本文介绍了如何使XML字符串加粗,下划线等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href="http://docs.fusioncharts.com/charts/contents/Styles/Font.html">http://docs.fusioncharts.com/charts/contents/Styles/Font.html

我想这一点,还有很多事情,但未能如愿。 这就是我想要的。

I tried this, along with a lot of things but failed to do so. Here's what I want.

<string name="ss">Bold. Underlined. Italic. Big. Small</string>

我想格式化字符串的一点点。 当它写大胆的,我想这是大胆...并同他人。

I want to format a little bit of the string. Where it's written bold, I want it to be bold...and same for others.

我尝试了很多的标签......但也没有什么工作,我无法找到任何关于谷歌左右。

I tried a lot of tags ...but well nothing worked, and I couldn't find anything on Google or SO.

我知道该怎么做,在一个TextView,但是这不是我想要的......

I know how to do it in a textview, but that's not what I want...

我要送一些文本资源的活动,显示它... 如果我做到了用不同的文字意见,我必须创建若干人,一个新的,每当我想大胆的文字,这是不是很优雅。

I'm sending some text resource to an activity that shows it... If I did it with different text views, I'd have to create several of them, a new one for whenever I want bold text, and that's not very elegant.

有没有办法来简单的做到这一点的XML文件中?或者一些其他的方式?

Is there a way to simple do this in the XML file ? or some other way ?

推荐答案

尝试在CDATA标签包裹你的标记的文字。例如:

Try wrapping your marked up text in CDATA tags. For example:

<string name="ss"><![CDATA[<b>Bold.</b> <u>Underlined.</u> <i>Italic.</i> <big>Big.</big> <small>Small</small>]]></string>

然后用Html.fromHtml无论你想要显示它:

And then use Html.fromHtml wherever you're wanting to display it:

Html.fromHtml(getString(R.string.ss))

这篇关于如何使XML字符串加粗,下划线等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆