> Documentation index: https://developer.android.com/reference/llms.txt

# SpannableStringKt

Added in 1.19.0

*** ** * ** ***


```
public final class SpannableStringKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `clearSpans(@NonNull Spannable receiver)` Clear all spans from this text. |
| `static final void` | `set( @NonNull Spannable receiver, @NonNull IntRange range, @NonNull Object span )` Add `span` to the `range` of the text. |
| `static final void` | `set(@NonNull Spannable receiver, int start, int end, @NonNull Object span)` Add `span` to the range `start`...`end` of the text. |
| `static final @NonNull Spannable` | `toSpannable(@NonNull CharSequence receiver)` Returns a new `Spannable` from `CharSequence`, or the source itself if it is already an instance of `SpannableString`. |

## Public methods

### clearSpans

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/core/text/SpannableString.kt+function:clearSpans) Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public static final void clearSpans(@NonNull Spannable receiver)
```

Clear all spans from this text.

### set

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/core/text/SpannableString.kt+function:set) Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public static final void set(
    @NonNull Spannable receiver,
    @NonNull IntRange range,
    @NonNull Object span
)
```

Add `span` to the `range` of the text.

```
val s = "Hello, World!".toSpannable()
s[0..5] = UnderlineSpan()
```

Note: The range end value is exclusive.

| See also |
|---|---|
| `setSpan` |   |

### set

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/core/text/SpannableString.kt+function:set) Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public static final void set(@NonNull Spannable receiver, int start, int end, @NonNull Object span)
```

Add `span` to the range `start`...`end` of the text.

```
val s = "Hello, World!".toSpannable()
s[0, 5] = UnderlineSpan()
```

Note: The `end` value is exclusive.

| See also |
|---|---|
| `setSpan` |   |

### toSpannable

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/core/text/SpannableString.kt+function:toSpannable) Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public static final @NonNull Spannable toSpannable(@NonNull CharSequence receiver)
```

Returns a new `Spannable` from `CharSequence`, or the source itself if it is already an instance of `SpannableString`.