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);
posted on 2014-11-26 10:07 leihupqrst 阅读(685) 评论(0) 编辑 收藏 举报