@UnstableApi
class SpanUtil


Utility methods for Android span styling.

Summary

Public functions

java-static Unit
addOrReplaceSpan(
    spannable: Spannable!,
    span: Any!,
    start: Int,
    end: Int,
    spanFlags: Int
)

Adds span to spannable between start and end, removing any existing spans of the same type and with the same indices and flags.

Public functions

addOrReplaceSpan

java-static fun addOrReplaceSpan(
    spannable: Spannable!,
    span: Any!,
    start: Int,
    end: Int,
    spanFlags: Int
): Unit

Adds span to spannable between start and end, removing any existing spans of the same type and with the same indices and flags.

This is useful for types of spans that don't make sense to duplicate and where the evaluation order might have an unexpected impact on the final text, e.g. .

Parameters
spannable: Spannable!

The Spannable to add span to.

span: Any!

The span object to be added.

start: Int

The start index to add the new span at.

end: Int

The end index to add the new span at.

spanFlags: Int

The flags to pass to setSpan.