textview设置不同格式字体颜色

来源:互联网 发布:海尔智能软件下载 编辑:程序博客网 时间:2024/05/18 00:56

SpannableStringBuilder style = new SpannableStringBuilder(sb.toString());
       style.setSpan(new RelativeSizeSpan(0.9f), attrName.length(), sb.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
       style.setSpan(new ForegroundColorSpan(context.getResources()
         .getColor(R.color.color_gray)), attrName.length(), sb.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
       settingNameTx.setText(style);

 

 

参考博客:http://aichixihongshi.iteye.com/blog/1207503

0 0
原创粉丝点击