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);

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。