Android:用代码修改一行文字中某几个字的颜色

TextView changeVideoQualityTxt = (TextView) rootView.findViewById(R.id.enter_wireless_display_txt);
String text1 = getString(R.string.enter_application_wireless_display);
SpannableStringBuilder style1 = new SpannableStringBuilder(text1);
style1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.high_light_color)), 13, 19, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
changeVideoQualityTxt.setText(style1);

如果想要在某一行文字中插入图片:

TextView changeVideoQualityTxt = (TextView) rootView.findViewById(R.id.choose_txt);
String text1 = getString(R.string.connect_display);
SpannableStringBuilder style1 = new SpannableStringBuilder(text1);
style1.setSpan(new ImageSpan(this, R.drawable.focus_txt_background), 13, 19, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
changeVideoQualityTxt.setText(style1);

原文地址:https://www.cnblogs.com/leihupqrst/p/4122538.html