如何添加在Android TextView中换行? [英] How to add a line break in an Android TextView?
本文介绍了如何添加在Android TextView中换行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想添加一个换行符在TextView中。
I am trying to add a line break in the TextView.
我想建议\ n,而是什么也不做。这里是我把我的文章。
I tried suggested \n but that does nothing. Here is how I set my texts.
TextView txtSubTitle = (TextView)findViewById(r.id.txtSubTitle);
txtSubTitle.setText(Html.fromHtml(getResources().getString(R.string.sample_string)));
这是我的字符串:<字符串名称=sample_string>有的检测线1 \ñ一些测试线2'; /串>
它应该显示像这样:
some test line 1
some test line 2
但它显示像这样:一些测试线1部分测试线2
我缺少的东西?
推荐答案
确定想通了:
<string name="sample_string"><![CDATA[some test line 1 <br />some test line 2]]></string>
所以包装在CDATA是必要的休息时间内加入如html标签
so wrap in CDATA is necessary and breaks added inside as html tags
感谢大家的帮助!
这篇关于如何添加在Android TextView中换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文