Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/text/Spanned#constants) \| [Methods](https://developer.android.com/reference/android/text/Spanned#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/text/Spanned#inhmethods)

# Spanned

*** ** * ** ***


`
public


interface
Spanned
`


`


implements

https://developer.android.com/reference/java/lang/CharSequence


`

|---|
| android.text.Spanned |

|---|
| Known indirect subclasses [Editable](https://developer.android.com/reference/android/text/Editable), [PrecomputedText](https://developer.android.com/reference/android/text/PrecomputedText), [Spannable](https://developer.android.com/reference/android/text/Spannable), [SpannableString](https://developer.android.com/reference/android/text/SpannableString), [SpannableStringBuilder](https://developer.android.com/reference/android/text/SpannableStringBuilder), [SpannedString](https://developer.android.com/reference/android/text/SpannedString) |---|---| | [Editable](https://developer.android.com/reference/android/text/Editable) | This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). | | [PrecomputedText](https://developer.android.com/reference/android/text/PrecomputedText) | A text which has the character metrics data. | | [Spannable](https://developer.android.com/reference/android/text/Spannable) | This is the interface for text to which markup objects can be attached and detached. | | [SpannableString](https://developer.android.com/reference/android/text/SpannableString) | This is the class for text whose content is immutable but to which markup objects can be attached and detached. | | [SpannableStringBuilder](https://developer.android.com/reference/android/text/SpannableStringBuilder) | This is the class for text whose content and markup can both be changed. | | [SpannedString](https://developer.android.com/reference/android/text/SpannedString) | This is the class for text whose content and markup are immutable. | |

<br />

*** ** * ** ***

This is the interface for text that has markup objects attached to
ranges of it. Not all text classes have mutable markup or text;
see `https://developer.android.com/reference/android/text/Spannable` for mutable markup and `https://developer.android.com/reference/android/text/Editable` for
mutable text.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_COMPOSING` This flag is set on spans that are being used to apply temporary styling information on the composing text of an input method, so that they can be found and removed when the composing text is being replaced. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_EXCLUSIVE_EXCLUSIVE` Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand to include text inserted at either their starting or ending point. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_EXCLUSIVE_INCLUSIVE` Non-0-length spans of type SPAN_EXCLUSIVE_INCLUSIVE expand to include text inserted at their ending point but not at their starting point. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_INCLUSIVE_EXCLUSIVE` Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand to include text inserted at their starting point but not at their ending point. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_INCLUSIVE_INCLUSIVE` Spans of type SPAN_INCLUSIVE_INCLUSIVE expand to include text inserted at either their starting or ending point. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_INTERMEDIATE` This flag will be set for intermediate span changes, meaning there is guaranteed to be another change following it. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_MARK_MARK` 0-length spans with type SPAN_MARK_MARK behave like text marks: they remain at their original offset when text is inserted at that offset. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_MARK_POINT` SPAN_MARK_POINT is a synonym for `https://developer.android.com/reference/android/text/Spanned#SPAN_INCLUSIVE_INCLUSIVE`. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_PARAGRAPH` SPAN_PARAGRAPH behaves like SPAN_INCLUSIVE_EXCLUSIVE (SPAN_MARK_MARK), except that if either end of the span is at the end of the buffer, that end behaves like _POINT instead (so SPAN_INCLUSIVE_INCLUSIVE if it starts in the middle and ends at the end, or SPAN_EXCLUSIVE_INCLUSIVE if it both starts and ends at the end). |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_POINT_MARK` SPAN_POINT_MARK is a synonym for `https://developer.android.com/reference/android/text/Spanned#SPAN_EXCLUSIVE_EXCLUSIVE`. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_POINT_MARK_MASK` Bitmask of bits that are relevent for controlling point/mark behavior of spans. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_POINT_POINT` 0-length spans with type SPAN_POINT_POINT behave like cursors: they are pushed forward by the length of the insertion when text is inserted at their offset. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_PRIORITY` The bits specified by the SPAN_PRIORITY bitmap determine the order of change notifications -- higher numbers go first. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_PRIORITY_SHIFT` The bits numbered just above SPAN_PRIORITY_SHIFT determine the order of change notifications -- higher numbers go first. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_USER` The bits specified by the SPAN_USER bitfield are available for callers to use to store scalar data associated with their span object. |
| `int` | `https://developer.android.com/reference/android/text/Spanned#SPAN_USER_SHIFT` The bits numbered SPAN_USER_SHIFT and above are available for callers to use to store scalar data associated with their span object. |

| ### Public methods ||
|---|---|
| ` abstract int` | ` https://developer.android.com/reference/android/text/Spanned#getSpanEnd(java.lang.Object)(https://developer.android.com/reference/java/lang/Object tag) ` Return the end of the range of text to which the specified markup object is attached, or -1 if the object is not attached. |
| ` abstract int` | ` https://developer.android.com/reference/android/text/Spanned#getSpanFlags(java.lang.Object)(https://developer.android.com/reference/java/lang/Object tag) ` Return the flags that were specified when `https://developer.android.com/reference/android/text/Spannable#setSpan(java.lang.Object,%20int,%20int,%20int)` was used to attach the specified markup object, or 0 if the specified object has not been attached. |
| ` abstract int` | ` https://developer.android.com/reference/android/text/Spanned#getSpanStart(java.lang.Object)(https://developer.android.com/reference/java/lang/Object tag) ` Return the beginning of the range of text to which the specified markup object is attached, or -1 if the object is not attached. |
| ` abstract <T> T[]` | ` https://developer.android.com/reference/android/text/Spanned#getSpans(int,%20int,%20java.lang.Class<T>)(int start, int end, https://developer.android.com/reference/java/lang/Class<T> type) ` Return an array of the markup objects attached to the specified slice of this CharSequence and whose type is the specified type or a subclass of it. |
| ` abstract int` | ` https://developer.android.com/reference/android/text/Spanned#nextSpanTransition(int,%20int,%20java.lang.Class)(int start, int limit, https://developer.android.com/reference/java/lang/Class<T> type) ` Return the first offset greater than `start` where a markup object of class `type` begins or ends, or `limit` if there are no starts or ends greater than `start` but less than `limit`. |

| ### Inherited methods |
|---|---|
| From interface ` https://developer.android.com/reference/java/lang/CharSequence ` |---|---| | ` abstract char` | ` https://developer.android.com/reference/java/lang/CharSequence#charAt(int)(int index) ` Returns the `char` value at the specified index. | | ` default https://developer.android.com/reference/java/util/stream/IntStream` | ` https://developer.android.com/reference/java/lang/CharSequence#chars()() ` Returns a stream of `int` zero-extending the `char` values from this sequence. | | ` default https://developer.android.com/reference/java/util/stream/IntStream` | ` https://developer.android.com/reference/java/lang/CharSequence#codePoints()() ` Returns a stream of code point values from this sequence. | | ` static int` | ` https://developer.android.com/reference/java/lang/CharSequence#compare(java.lang.CharSequence,%20java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence cs1, https://developer.android.com/reference/java/lang/CharSequence cs2) ` Compares two `CharSequence` instances lexicographically. | | ` default void` | ` https://developer.android.com/reference/java/lang/CharSequence#getChars(int,%20int,%20char[],%20int)(int srcBegin, int srcEnd, char[] dst, int dstBegin) ` Copies characters from this sequence into the given destination array. | | ` default boolean` | ` https://developer.android.com/reference/java/lang/CharSequence#isEmpty()() ` Returns `true` if this character sequence is empty. | | ` abstract int` | ` https://developer.android.com/reference/java/lang/CharSequence#length()() ` Returns the length of this character sequence. | | ` abstract https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/java/lang/CharSequence#subSequence(int,%20int)(int start, int end) ` Returns a `CharSequence` that is a subsequence of this sequence. | | ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/CharSequence#toString()() ` Returns a string containing the characters in this sequence in the same order as this sequence. | ||

## Constants

### SPAN_COMPOSING

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_COMPOSING
```

This flag is set on spans that are being used to apply temporary
styling information on the composing text of an input method, so that
they can be found and removed when the composing text is being
replaced.

<br />

Constant Value:

256
(0x00000100)


### SPAN_EXCLUSIVE_EXCLUSIVE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_EXCLUSIVE_EXCLUSIVE
```

Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand
to include text inserted at either their starting or ending point.
They can never have a length of 0 and are automatically removed
from the buffer if all the text they cover is removed.

<br />

Constant Value:

33
(0x00000021)


### SPAN_EXCLUSIVE_INCLUSIVE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_EXCLUSIVE_INCLUSIVE
```

Non-0-length spans of type SPAN_EXCLUSIVE_INCLUSIVE expand
to include text inserted at their ending point but not at their
starting point. When 0-length, they behave like points.

<br />

Constant Value:

34
(0x00000022)


### SPAN_INCLUSIVE_EXCLUSIVE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_INCLUSIVE_EXCLUSIVE
```

Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
to include text inserted at their starting point but not at their
ending point. When 0-length, they behave like marks.

<br />

Constant Value:

17
(0x00000011)


### SPAN_INCLUSIVE_INCLUSIVE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_INCLUSIVE_INCLUSIVE
```

Spans of type SPAN_INCLUSIVE_INCLUSIVE expand
to include text inserted at either their starting or ending point.

<br />

Constant Value:

18
(0x00000012)


### SPAN_INTERMEDIATE

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_INTERMEDIATE
```

This flag will be set for intermediate span changes, meaning there
is guaranteed to be another change following it. Typically it is
used for `https://developer.android.com/reference/android/text/Selection` which automatically uses this with the first
offset it sets when updating the selection.

<br />

Constant Value:

512
(0x00000200)


### SPAN_MARK_MARK

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_MARK_MARK
```

0-length spans with type SPAN_MARK_MARK behave like text marks:
they remain at their original offset when text is inserted
at that offset. Conceptually, the text is added after the mark.

<br />

Constant Value:

17
(0x00000011)


### SPAN_MARK_POINT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_MARK_POINT
```

SPAN_MARK_POINT is a synonym for `https://developer.android.com/reference/android/text/Spanned#SPAN_INCLUSIVE_INCLUSIVE`.

<br />

Constant Value:

18
(0x00000012)


### SPAN_PARAGRAPH

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_PARAGRAPH
```

SPAN_PARAGRAPH behaves like SPAN_INCLUSIVE_EXCLUSIVE
(SPAN_MARK_MARK), except that if either end of the span is
at the end of the buffer, that end behaves like _POINT
instead (so SPAN_INCLUSIVE_INCLUSIVE if it starts in the
middle and ends at the end, or SPAN_EXCLUSIVE_INCLUSIVE
if it both starts and ends at the end).


Its endpoints must be the start or end of the buffer or
immediately after a \\n character, and if the \\n
that anchors it is deleted, the endpoint is pulled to the
next \\n that follows in the buffer (or to the end of
the buffer). If a span with SPAN_PARAGRAPH flag is pasted
into another text and the paragraph boundary constraint
is not satisfied, the span is discarded.

<br />

Constant Value:

51
(0x00000033)


### SPAN_POINT_MARK

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_POINT_MARK
```

SPAN_POINT_MARK is a synonym for `https://developer.android.com/reference/android/text/Spanned#SPAN_EXCLUSIVE_EXCLUSIVE`.

<br />

Constant Value:

33
(0x00000021)


### SPAN_POINT_MARK_MASK

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_POINT_MARK_MASK
```

Bitmask of bits that are relevent for controlling point/mark behavior
of spans.

MARK and POINT are conceptually located *between* two adjacent characters.
A MARK is "attached" to the character before, while a POINT will stick to the character
after. The insertion cursor is conceptually located between the MARK and the POINT.

As a result, inserting a new character between a MARK and a POINT will leave the MARK
unchanged, while the POINT will be shifted, now located after the inserted character and
still glued to the same character after it.

Depending on whether the insertion happens at the beginning or the end of a span, the span
will hence be expanded to *include* the new character (when the span is using a MARK at
its beginning or a POINT at its end) or it will be *excluded*.

Note that *before* and *after* here refer to offsets in the String, which are
independent from the visual representation of the text (left-to-right or right-to-left).

<br />

Constant Value:

51
(0x00000033)


### SPAN_POINT_POINT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_POINT_POINT
```

0-length spans with type SPAN_POINT_POINT behave like cursors:
they are pushed forward by the length of the insertion when text
is inserted at their offset.
The text is conceptually inserted before the point.

<br />

Constant Value:

34
(0x00000022)


### SPAN_PRIORITY

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_PRIORITY
```

The bits specified by the SPAN_PRIORITY bitmap determine the order
of change notifications -- higher numbers go first. You probably
don't need to set this; it is used so that when text changes, the
text layout gets the chance to update itself before any other
callbacks can inquire about the layout of the text.

<br />

Constant Value:

16711680
(0x00ff0000)


### SPAN_PRIORITY_SHIFT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_PRIORITY_SHIFT
```

The bits numbered just above SPAN_PRIORITY_SHIFT determine the order
of change notifications -- higher numbers go first. You probably
don't need to set this; it is used so that when text changes, the
text layout gets the chance to update itself before any other
callbacks can inquire about the layout of the text.

<br />

Constant Value:

16
(0x00000010)


### SPAN_USER

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_USER
```

The bits specified by the SPAN_USER bitfield are available
for callers to use to store scalar data associated with their
span object.

<br />

Constant Value:

-16777216
(0xff000000)


### SPAN_USER_SHIFT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SPAN_USER_SHIFT
```

The bits numbered SPAN_USER_SHIFT and above are available
for callers to use to store scalar data associated with their
span object.

<br />

Constant Value:

24
(0x00000018)


## Public methods

### getSpanEnd

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int getSpanEnd (Object tag)
```

Return the end of the range of text to which the specified
markup object is attached, or -1 if the object is not attached.

<br />

| Parameters ||
|---|---|
| `tag` | `Object` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getSpanFlags

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int getSpanFlags (Object tag)
```

Return the flags that were specified when `https://developer.android.com/reference/android/text/Spannable#setSpan(java.lang.Object,%20int,%20int,%20int)` was
used to attach the specified markup object, or 0 if the specified
object has not been attached.

<br />

| Parameters ||
|---|---|
| `tag` | `Object` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getSpanStart

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int getSpanStart (Object tag)
```

Return the beginning of the range of text to which the specified
markup object is attached, or -1 if the object is not attached.

<br />

| Parameters ||
|---|---|
| `tag` | `Object` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getSpans

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract T[] getSpans (int start, 
                int end, 
                Class<T> type)
```

Return an array of the markup objects attached to the specified
slice of this CharSequence and whose type is the specified type
or a subclass of it. Specify Object.class for the type if you
want all the objects regardless of type.

<br />

| Parameters ||
|---|---|
| `start` | `int` <br /> |
| `end` | `int` <br /> |
| `type` | `Class` <br /> |

| Returns ||
|---|---|
| `T[]` | <br /> |

### nextSpanTransition

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int nextSpanTransition (int start, 
                int limit, 
                Class<T> type)
```

Return the first offset greater than `start` where a markup
object of class `type` begins or ends, or `limit`
if there are no starts or ends greater than `start` but less
than `limit`. Specify `null` or Object.class for
the type if you want every transition regardless of type.

<br />

| Parameters ||
|---|---|
| `start` | `int` <br /> |
| `limit` | `int` <br /> |
| `type` | `Class` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |