string.xml
<string name="year_money">年收入:  %1$s  (万元)</string>
 是空格
%1$d是占位符
mTextView = (TextView) findViewById(R.id.textview); String text = getString(R.string.year_money, 3000); int index[] = new int[3]; index[0] = text.indexOf("年收入:"); index[1] = text.indexOf("3000"); index[2] = text.indexOf("(万元)"); SpannableStringBuilder style = new SpannableStringBuilder(text); style.setSpan(new ForegroundColorSpan(Color.GREEN), index[0], index[0] + 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); style.setSpan(new ForegroundColorSpan(Color.RED), index[1], index[1] + 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); style.setSpan(new ForegroundColorSpan(Color.BLUE), index[2], index[2] + 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); mTextView.setText(style);