码迷,mamicode.com
首页 > 移动开发 > 详细

android同一个TextView设置不同颜色字体

时间:2015-04-07 11:31:24      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

 1     SpannableStringBuilder style = new SpannableStringBuilder(str);
 2             style.setSpan(
 3                     new ForegroundColorSpan(getResources().getColor(
 4                             R.color.tab_sel_color)), 0, t1.length() - 1,
 5                     Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
 6             style.setSpan(
 7                     new ForegroundColorSpan(getResources().getColor(
 8                             R.color.tab_sel_color)), t1.length() + 3,
 9                     t1.length() + 3 + t2.length(),
10                     Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
11             mCarGuidancePrice.setText(style);

 

android同一个TextView设置不同颜色字体

标签:

原文地址:http://www.cnblogs.com/luanmage/p/4397622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!