questionDesTextView=(TextView)findViewById(R.id.question_des);
        SpannableStringBuilder builder = new SpannableStringBuilder(questionDesTextView.getText().toString());
        //ForegroundColorSpan 为文字前景色,BackgroundColorSpan为文字背景色
        ForegroundColorSpan blackSpan = new ForegroundColorSpan(Color.BLACK);
        ForegroundColorSpan graySpan=new ForegroundColorSpan(Color.GRAY);

//第二个参数是开始的下标,第三个参数是结束的下标 builder.setSpan(blackSpan,
0,4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(graySpan,4,9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); questionDesTextView.setText(builder);

 

相关文章:

  • 2021-04-22
  • 2021-09-29
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-08-20
相关资源
相似解决方案