Android富文本

String content = detailDTO.getContent();//要改变的字符串

int i = content.indexOf("@");//获取@的下标

SpannableStringBuilder spannableStringBuilder =new SpannableStringBuilder(content);

spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.BLUE),i,i+7,Spanned.SPAN_INCLUSIVE_EXCLUSIVE);//第i开始,i+7结束

spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.BLUE),0,9, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);//0开始,9结束

text.setText(spannableStringBuilder);//引用到空间中

推荐阅读更多精彩内容