我有一个字符串,例如:sed ':a;/plot/!{n;ba;};:b;n;s///;bb'
我想在花括号和带括号的括号之间更改颜色,我该怎么办?
答案 0 :(得分:2)
这是通过创建如下所示的SpannableStringBuilder
来完成的:
SpannableStringBuilder builder = new SpannableStringBuilder();
String red = "this is red";
SpannableString redSpannable= new SpannableString(red);
redSpannable.setSpan(new ForegroundColorSpan(Color.RED), 0, red.length(), 0);
builder.append(redSpannable);
String white = "this is white";
SpannableString whiteSpannable= new SpannableString(white);
whiteSpannable.setSpan(new ForegroundColorSpan(Color.WHITE), 0, white.length(), 0);
builder.append(whiteSpannable);
textView.setText(builder, BufferType.SPANNABLE);
有关更多信息,请查看here