Android的TextView的以粗普通文本 [英] Android TextView in BOLD and Normal text
本文介绍了Android的TextView的以粗普通文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我彻底搜查的SO,但没得到我的问题的答案。
I thoroughly searched on SO but didnt get answer of my question.
我想成立一个段落,我会用它设置在XML
I want to set a paragraph, I will set it in XML using
文本包含标题和步骤和普通的文本。我想使标题和步骤大胆和休息普通文本。
The text contains Title and Steps and regular text. I want to make the Title and Steps in bold and rest in normal text.
我可以用不同的做到这一点,但我怎么能做到这一点在同一个TextView中。
I can do this by using different 's but how can I do it in the same TextView.
我的意思是使用相同的TextView我怎么可以设置不同的句子不同的属性?
I mean using the same TextView how can I set different attributes for different sentences?
推荐答案
在您的字符串文件
<string name="your_text">
<![CDATA[
<p> <b>Title</b> </p>
<p><b><i>Step 1</i></b><p>step1 content content content content content content</p></p>
<p><b><i>Step 2</i></b><p>step2 content content content content content content content</p></p>
]]>
</string>
然后在你的活动
TextView tv=(TextView)findViewById(R.id.textView1);
tv.setText(Html.fromHtml(getString(R.string.your_text)));
和输出
这篇关于Android的TextView的以粗普通文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文