我在SpannableStringBuilder中有很少的重叠跨度。我想定义它们将实现到Text的顺序。 Spannable有int标志
int SPAN_PRIORITY = 16711680;
int SPAN_PRIORITY_SHIFT = 16;
我该如何使用它们? Spannable优先级有多少级别? 什么是默认值?
答案 0 :(得分:1)
要定义priority
,你必须利用位神奇:
int priority = 123; // Should be in range [0..255].
int spanFlags = 0;
// ...
// Cleaning up priority bits.
spanFlags &= ~Spannable.SPAN_PRIORITY;
// Injecting priority bits.
spanFlags |= (priority << Spannable.SPAN_PRIORITY_SHIFT) & Spannable.SPAN_PRIORITY;
// ...
sb.setSpan(what, start, end, spanFlags);