当前位置: 代码迷 >> Android >> Android一个TextView设立多种颜色
  详细解决方案

Android一个TextView设立多种颜色

热度:13   发布时间:2016-04-28 03:12:49.0
Android一个TextView设置多种颜色

有时候一个文本框为了强调内容需要显示不同颜色,用以下代码可以轻松实现


 //为文本框设置多种颜色	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);



  相关解决方案