android TextView文字加粗

来源:互联网 发布:淘宝 中国历代名家画集 编辑:程序博客网 时间:2024/05/16 07:49
 

android中TextView中文字体粗体的方法 (android:textStyle="bold"来使字体显示为粗体,但是这只对英文有效)

分类: android 4286人阅读 评论(0) 收藏 举报
androidxml

TextView在xml中可以定义android:textStyle="bold"来使字体显示为粗体,但是这只对英文有效,当你的TextView要显示中文的时候要在code中设置粗体的paint来实现,如下:

1 TextView title = new TextView(context);//或从xml导入
2 TextPaint paint = title.getPaint();
3 paint.setFakeBoldText(true); 

这样就可以显示粗体了。

 

http://www.189works.com/article-42832-1.html

0 0
原创粉丝点击