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

# CharacterStyle

*** ** * ** ***

` public abstract class CharacterStyle `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.text.style.CharacterStyle |

Known direct subclasses [BackgroundColorSpan](https://developer.android.com/reference/android/text/style/BackgroundColorSpan), [ClickableSpan](https://developer.android.com/reference/android/text/style/ClickableSpan), [ForegroundColorSpan](https://developer.android.com/reference/android/text/style/ForegroundColorSpan), [MaskFilterSpan](https://developer.android.com/reference/android/text/style/MaskFilterSpan), [MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan), [StrikethroughSpan](https://developer.android.com/reference/android/text/style/StrikethroughSpan), [SuggestionRangeSpan](https://developer.android.com/reference/android/text/style/SuggestionRangeSpan), [SuggestionSpan](https://developer.android.com/reference/android/text/style/SuggestionSpan), [UnderlineSpan](https://developer.android.com/reference/android/text/style/UnderlineSpan) [BackgroundColorSpan](https://developer.android.com/reference/android/text/style/BackgroundColorSpan) Changes the background color of the text to which the span is attached. [ClickableSpan](https://developer.android.com/reference/android/text/style/ClickableSpan) If an object of this type is attached to the text of a TextView with a movement method of LinkMovementMethod, the affected spans of text can be selected. [ForegroundColorSpan](https://developer.android.com/reference/android/text/style/ForegroundColorSpan) Changes the color of the text to which the span is attached. [MaskFilterSpan](https://developer.android.com/reference/android/text/style/MaskFilterSpan) Span that allows setting a `https://developer.android.com/reference/android/graphics/MaskFilter` to the text it's attached to. [MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan) The classes that affect character-level text formatting in a way that changes the width or height of characters extend this class. [StrikethroughSpan](https://developer.android.com/reference/android/text/style/StrikethroughSpan) A span that strikes through the text it's attached to. [SuggestionRangeSpan](https://developer.android.com/reference/android/text/style/SuggestionRangeSpan) A SuggestionRangeSpan is used to show which part of an EditText is affected by a suggestion popup window. [SuggestionSpan](https://developer.android.com/reference/android/text/style/SuggestionSpan) Holds suggestion candidates for the text enclosed in this span. [UnderlineSpan](https://developer.android.com/reference/android/text/style/UnderlineSpan) A span that underlines the text it's attached to. Known indirect subclasses [AbsoluteSizeSpan](https://developer.android.com/reference/android/text/style/AbsoluteSizeSpan), [DynamicDrawableSpan](https://developer.android.com/reference/android/text/style/DynamicDrawableSpan), [ImageSpan](https://developer.android.com/reference/android/text/style/ImageSpan), [LocaleSpan](https://developer.android.com/reference/android/text/style/LocaleSpan), [RelativeSizeSpan](https://developer.android.com/reference/android/text/style/RelativeSizeSpan), [ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan), [ScaleXSpan](https://developer.android.com/reference/android/text/style/ScaleXSpan), [StyleSpan](https://developer.android.com/reference/android/text/style/StyleSpan), [SubscriptSpan](https://developer.android.com/reference/android/text/style/SubscriptSpan), [SuperscriptSpan](https://developer.android.com/reference/android/text/style/SuperscriptSpan), [TextAppearanceSpan](https://developer.android.com/reference/android/text/style/TextAppearanceSpan), [TextLinks.TextLinkSpan](https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan), [TypefaceSpan](https://developer.android.com/reference/android/text/style/TypefaceSpan), [URLSpan](https://developer.android.com/reference/android/text/style/URLSpan) [AbsoluteSizeSpan](https://developer.android.com/reference/android/text/style/AbsoluteSizeSpan) A span that changes the size of the text it's attached to. [DynamicDrawableSpan](https://developer.android.com/reference/android/text/style/DynamicDrawableSpan) Span that replaces the text it's attached to with a `https://developer.android.com/reference/android/graphics/drawable/Drawable` that can be aligned with the bottom or with the baseline of the surrounding text. [ImageSpan](https://developer.android.com/reference/android/text/style/ImageSpan) Span that replaces the text it's attached to with a `https://developer.android.com/reference/android/graphics/drawable/Drawable` that can be aligned with the bottom or with the baseline of the surrounding text. [LocaleSpan](https://developer.android.com/reference/android/text/style/LocaleSpan) Changes the `https://developer.android.com/reference/java/util/Locale` of the text to which the span is attached. [RelativeSizeSpan](https://developer.android.com/reference/android/text/style/RelativeSizeSpan) Uniformly scales the size of the text to which it's attached by a certain proportion. [ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan) [ScaleXSpan](https://developer.android.com/reference/android/text/style/ScaleXSpan) Scales horizontally the size of the text to which it's attached by a certain factor. [StyleSpan](https://developer.android.com/reference/android/text/style/StyleSpan) Span that allows setting the style of the text it's attached to. [SubscriptSpan](https://developer.android.com/reference/android/text/style/SubscriptSpan) The span that moves the position of the text baseline lower. [SuperscriptSpan](https://developer.android.com/reference/android/text/style/SuperscriptSpan) The span that moves the position of the text baseline higher. [TextAppearanceSpan](https://developer.android.com/reference/android/text/style/TextAppearanceSpan) Sets the text appearance using the given `https://developer.android.com/reference/android/R.styleable#TextAppearance` attributes. [TextLinks.TextLinkSpan](https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan) A ClickableSpan for a TextLink. [TypefaceSpan](https://developer.android.com/reference/android/text/style/TypefaceSpan) Span that updates the typeface of the text it's attached to. [URLSpan](https://developer.android.com/reference/android/text/style/URLSpan) Implementation of the `https://developer.android.com/reference/android/text/style/ClickableSpan` that allows setting a url string.   

*** ** * ** ***

The classes that affect character-level text formatting extend this class. Most extend its subclass `https://developer.android.com/reference/android/text/style/MetricAffectingSpan`, but simple ones may just implement `https://developer.android.com/reference/android/text/style/UpdateAppearance`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/text/style/CharacterStyle#CharacterStyle()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/text/style/CharacterStyle` | ` https://developer.android.com/reference/android/text/style/CharacterStyle#getUnderlying()() ` Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by `https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)`, returns the underlying CharacterStyle. |
| ` abstract void` | ` https://developer.android.com/reference/android/text/style/CharacterStyle#updateDrawState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint tp) ` |
| ` static https://developer.android.com/reference/android/text/style/CharacterStyle` | ` https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)(https://developer.android.com/reference/android/text/style/CharacterStyle cs) ` A given CharacterStyle can only applied to a single region of a given Spanned. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### CharacterStyle

```
public CharacterStyle ()
```

<br />

<br />

## Public methods

### getUnderlying

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

```
public CharacterStyle getUnderlying ()
```

Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by `https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)`, returns the underlying CharacterStyle.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/style/CharacterStyle` | <br /> |

### updateDrawState

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

```
public abstract void updateDrawState (TextPaint tp)
```

<br />

<br />

| Parameters ||
|---|---|
| `tp` | `TextPaint` <br /> |

### wrap

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

```
public static CharacterStyle wrap (CharacterStyle cs)
```

A given CharacterStyle can only applied to a single region of a given Spanned. If you need to attach the same CharacterStyle to multiple regions, you can use this method to wrap it with a new object that will have the same effect but be a distinct object so that it can also be attached without conflict.

<br />

| Parameters ||
|---|---|
| `cs` | `CharacterStyle` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/style/CharacterStyle` | <br /> |