码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-11-26 11:08:22      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:android   style   io   color   os   sp   for   on   bs   

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

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

标签:android   style   io   color   os   sp   for   on   bs   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!