android html.fromhtml 字体加粗,Android Html设置TextView的颜色、加粗样式
01、概述
在開發需求中,會遇到字符串中的某個部分變色,加粗的需求。當然可是使用SpannableString 來實現,這里記錄一下通過Html方式來實現這種效果
textView.setText(Html.fromHtml(this.getString(R.string.ceshi,?"01.01",??"26")));
textView1.setText(Html.fromHtml(this.getString(R.string.ceshi1,?"01.01",??"26")));
textView2.setText(Html.fromHtml(this.getString(R.string.ceshi2,?"不加粗")));
不轉義:生日(加粗)=?%1$s?年齡(不加粗)=?%2$s]]>
—轉義:生日(加粗)=?%1$s?年齡(不加粗)=?%2$s
不加粗:%1$s
代碼:
textView3.setText(String.format(getString(R.string.ceshi3),?9));
textView4.setText(String.format(getString(R.string.ceshi4),"張三"));
資源:
消息個數(%1$d)
你的名字:%1$s
這里記錄幾個字符,有其他特殊需求,可以參考Html 手冊?http://www.w3school.com.cn/tags/html_ref_symbols.html
代碼:
textView5.setText(String.format(getString(R.string.ceshi5),?22));
textView6.setText(String.format(getString(R.string.ceshi6)));
textView7.setText(String.format(getString(R.string.ceshi7)));
資源:
年齡\u2000%1$d歲
加載中\u2026
數字6&?#8211;20范圍
總結
以上是生活随笔為你收集整理的android html.fromhtml 字体加粗,Android Html设置TextView的颜色、加粗样式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 抓蚂蚁下一句是什么呢?
- 下一篇: 国内android应用商城中程序隐私泄露