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
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).