Explain the meaning of Span flags like SPAN_EXCLUSIVE_EXCLUSIVE

前端 未结 3 1254
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 03:39

Can someone clearly explain with examples what each of the span flags like SPAN_EXCLUSIVE_EXCLUSIVE and SPAN_MARK_MARK mean and when to use what fl

3条回答
  •  醉酒成梦
    2020-11-28 04:02

    Does "expand to include" refer to edits made after inserting the spans?

    Yes. For example, let's suppose we have the following:

    The quick fox jumped.

    If we used SPAN_EXCLUSIVE_EXCLUSIVE on the boldface span, and we insert text in the middle of the span, it is still boldface:

    The quick brown fox jumped.

    However, if we insert text at the beginning or the end of the boldface span, the inserted text is not boldface:

    The really quick fox jumped.

    If, however, we had used SPAN_INCLUSIVE_EXCLUSIVE, then inserting text at the beginning would be included as part of the span, and we would have:

    The really quick fox jumped.

    Does it mean that these flags do NOT affect Spannables with immutable text?

    I would say that they have limited use for immutable text. Mostly, these will be used with SpannableStringBuilder or things that use one under the covers (e.g., EditText).

提交回复
热议问题