Android中让TextView字体部分显示颜色:代码如下:
private TextView tvRightMainMenu;tvRightMainMenu = (TextView)findViewById(R.id.tv_main_right_top_menu);
//设置右上角TextView的颜色 SpannableStringBuilder builder = new SpannableStringBuilder(tvRightMainMenu.getText().toString()); ForegroundColorSpan span = new ForegroundColorSpan(Color.BLUE); builder.setSpan(span,1,6, Spannable.SPAN_INCLUSIVE_INCLUSIVE); tvRightMainMenu.setText(builder);
效果如下: