Back to Exoplayer

SpanUtil (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/text/span/SpanUtil.html

latest3.2 KB
Original Source

Package com.google.android.exoplayer2.text.span

Class SpanUtil


[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classSpanUtilextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.

Utility methods for Android span styling.

Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description | | --- | --- | --- | | static void | addOrReplaceSpan​(Spannable spannable, Object span, int start, int end, int spanFlags) | Deprecated.

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

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

- 

addOrReplaceSpan

public static void addOrReplaceSpan​([Spannable](https://developer.android.com/reference/android/text/Spannable.html "class or interface in android.text")spannable,[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")span,
                                    int start,
                                    int end,
                                    int spanFlags)

Deprecated.

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.

Parameters:spannable - The Spannable to add span to.span - The span object to be added.start - The start index to add the new span at.end - The end index to add the new span at.spanFlags - The flags to pass to Spannable.setSpan(Object, int, int, int).