SpanUtil
@UnstableApi
class SpanUtil
Utility methods for Android span styling.
Summary
Public functions |
|
|---|---|
java-static Unit |
addInheritedRelativeSizeSpan(Modifies the size of the text between |
java-static Unit |
Adds |
Public functions
addInheritedRelativeSizeSpan
java-static fun addInheritedRelativeSizeSpan(
spannable: Spannable!,
size: Float,
start: Int,
end: Int,
spanFlags: Int
): Unit
Modifies the size of the text between start and end relative to any existing RelativeSizeSpan instances which cover at least the same range.
RelativeSizeSpan instances which only cover a part of the text between start and end are ignored.
A new RelativeSizeSpan instance is added between start and end with its sizeChange value computed by modifying the size parameter by the
sizeChange of RelativeSizeSpan instances covering between start and
end.
RelativeSizeSpan instances with the same start, end, and
spanFlags are removed.
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. ForegroundColorSpan.