有时候一个文本框为了强调内容需要显示不同颜色,用以下代码可以轻松实现
//为文本框设置多种颜色
textView=(TextView)findViewById(R.id.text_show);
SpannableStringBuilder style = new SpannableStringBuilder("备注:签收人(张三)");
style.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
style.setSpan(new ForegroundColorSpan(Color.RED), 7, 9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(style);原文地址:http://blog.csdn.net/pengkv/article/details/42113225