int mainTextLength = mainText.length();
int secureInfoLength = getShortMessage.getSecureInfo.length();
SpannableStringBuilder style = new SpannableStringBuilder(mainText+getShortMessage.getSecureInfo);
text1.setTextColor(0XFF666666);//字默认颜色
text1.setText(style);
int secureInfoLength = getShortMessage.getSecureInfo.length();
SpannableStringBuilder style = new SpannableStringBuilder(mainText+getShortMessage.getSecureInfo);
//底的颜色
style.setSpan(
new BackgroundColorSpan(Color.GREEN),mainTextLength,mainTextLength+secureInfoLength,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
//字的颜色
style.setSpan(
new ForegroundColorSpan(Color.RED),mainTextLength,mainTextLength+secureInfoLength,
Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
text1.setTextColor(0XFF666666);//字默认颜色
text1.setText(style);