码迷,mamicode.com
首页 > 其他好文 > 详细

SpannableString用法注意

时间:2014-11-12 14:56:37      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:style   color   ar   os   使用   sp   for   strong   on   

正确的方法:

使用AbsoluteSizeSpan时要每次都new一个新对象出来,如果定义好一个,连续使用,则只有最后一个生效。 前面使用的都回失去效果

 

如下使用:

SpannableString spanString = new SpannableString(sb.toString());

            

            spanString.setSpan(new AbsoluteSizeSpan(90), firstMarkStart, firstMarkEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            spanString.setSpan(new ForegroundColorSpan(R.color.orange_color), firstMarkStart, firstMarkEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            

            spanString.setSpan(new AbsoluteSizeSpan(90), secondMarkStart, secondMarkEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            spanString.setSpan(new ForegroundColorSpan(R.color.orange_color), secondMarkStart, secondMarkEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            

            this.timerLabel.setText(spanString);

SpannableString用法注意

标签:style   color   ar   os   使用   sp   for   strong   on   

原文地址:http://www.cnblogs.com/feitianlee/p/4092267.html

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