构建SpanbableStringBuilder的标志变量是什么



我在Google文档中读取标志参数,但我找不到它到底在做什么。例如,在下面的代码中:

SpannableStringBuilder builder1 = new SpannableStringBuilder();
builder1.append("hi");
builder1.append("this is test");
builder1.setSpan(new ForegroundColorSpan(Color.RED), 0, 7, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
myTextView.setText(builder1);

如果您更改第四参数并设置这样的变量是没有区别的:spanned.span_inclusive_inclusive,spanned.span_inclusive_exclusive,spanned.span_exclusive_exclusive,spanned.span_exclusive_exclusive。

结果没有差异。

但是运行此代码时:

SpannableStringBuilder builder1 = new SpannableStringBuilder();
builder1.append("hi");
builder1.append("this is test");
builder1.setSpan(new ForegroundColorSpan(Color.RED), 0, 7, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
SpannableStringBuilder builder2 = new SpannableStringBuilder();
builder1.append("second test this is going to be different");
builder1.setSpan(new BackgroundColorSpan(Color.BLUE), 10, 15, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
SpannableStringBuilder all = new SpannableStringBuilder();
all.append(builder2);
all.insert(0, "n");
all.insert(0, builder1);

您会根据第四参数获得不同的结果

有人可以解释为什么会发生这种情况吗?

设置标志是在用于应用输入方法的构图文本上应用临时样式信息的跨度设置

相关内容

  • 没有找到相关文章

最新更新