SpannableStringBuilder的用法

来源:互联网 发布:拼模特卡软件 编辑:程序博客网 时间:2024/05/01 10:36
String reply="小明";SpannableStringBuilder builder = new SpannableStringBuilder(reply);ForegroundColorSpan yellowSpan = new ForegroundColorSpan(context      .getResources().getColor(R.color.red_text));builder.setSpan(yellowSpan, 0, builder.length(),      Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView tv = new TextView(context);
tv.append(“笑话”).append(builder);
结果为笑话小明
0 0