Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
    
    
  
  
    
    
  
  
CharacterStyle
  public
  
  
  abstract
  class
  CharacterStyle
  
    extends Object
  
  
  
  
  
  
  
    
      | 
          Known direct subclasses
          
  
  
    
  
  
    
      
        | BackgroundColorSpan | Changes the background color of the text to which the span is attached. |  
        | 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 | Changes the color of the text to which the span is attached. |  
        | MaskFilterSpan | Span that allows setting a MaskFilterto the text it's attached to. |  
        | MetricAffectingSpan | The classes that affect character-level text formatting in a way that
 changes the width or height of characters extend this class. |  
        | StrikethroughSpan | A span that strikes through the text it's attached to. |  
        | SuggestionRangeSpan | A SuggestionRangeSpan is used to show which part of an EditText is affected by a suggestion
 popup window. |  
        | SuggestionSpan | Holds suggestion candidates for the text enclosed in this span. |  
        | UnderlineSpan | A span that underlines the text it's attached to. |  | 
  
  
  
  
    
      | 
          Known indirect subclasses
          
   AbsoluteSizeSpan, DynamicDrawableSpan , ImageSpan , LocaleSpan , RelativeSizeSpan , ReplacementSpan , ScaleXSpan , StyleSpan , SubscriptSpan , SuperscriptSpan , TextAppearanceSpan , TextLinks.TextLinkSpan , TypefaceSpan , URLSpan 
    
  
  
    
      
        | AbsoluteSizeSpan | A span that changes the size of the text it's attached to. |  
        | DynamicDrawableSpan | Span that replaces the text it's attached to with a Drawablethat can be aligned with
 the bottom or with the baseline of the surrounding text. |  
        | ImageSpan | Span that replaces the text it's attached to with a Drawablethat can be aligned with
 the bottom or with the baseline of the surrounding text. |  
        | LocaleSpan | Changes the Localeof the text to which the span is attached. |  
        | RelativeSizeSpan | Uniformly scales the size of the text to which it's attached by a certain proportion. |  
        | ReplacementSpan |  |  
        | ScaleXSpan | Scales horizontally the size of the text to which it's attached by a certain factor. |  
        | StyleSpan | Span that allows setting the style of the text it's attached to. |  
        | SubscriptSpan | The span that moves the position of the text baseline lower. |  
        | SuperscriptSpan | The span that moves the position of the text baseline higher. |  
        | TextAppearanceSpan | Sets the text appearance using the given TextAppearanceattributes. |  
        | TextLinks.TextLinkSpan | A ClickableSpan for a TextLink. |  
        | TypefaceSpan | Span that updates the typeface of the text it's attached to. |  
        | URLSpan | Implementation of the ClickableSpanthat allows setting a url string. |  | 
  
    
  The classes that affect character-level text formatting extend this
 class.  Most extend its subclass MetricAffectingSpan, but simple
 ones may just implement UpdateAppearance.
Summary
| Inherited methods | 
|---|
| 
    From class
      
        
          java.lang.Object
        
      
      
  
  
  
    | 
        
        
        
        
        
        Object | 
      clone()
      Creates and returns a copy of this object.
        
    
 |  
  
  
    | 
        
        
        
        
        
        boolean | 
      equals(Object obj)
      Indicates whether some other object is "equal to" this one.
        
    
 |  
  
  
    | 
        
        
        
        
        
        void | 
      finalize()
      Called by the garbage collector on an object when garbage collection
 determines that there are no more references to the object.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        Class<?> | 
      getClass()
      Returns the runtime class of this Object. |  
  
  
    | 
        
        
        
        
        
        int | 
      hashCode()
      Returns a hash code value for the object.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        void | 
      notify()
      Wakes up a single thread that is waiting on this object's
 monitor.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        void | 
      notifyAll()
      Wakes up all threads that are waiting on this object's monitor.
        
    
 |  
  
  
    | 
        
        
        
        
        
        String | 
      toString()
      Returns a string representation of the object.
        
    
 |  
  
  
    | 
        
        
        
        final
        
        void | 
      wait(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 | 
      wait(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 | 
      wait()
      Causes the current thread to wait until it is awakened, typically
 by being notified or interrupted.
        
    
 |  | 
Public constructors
    CharacterStyle
    
public CharacterStyle ()
    
    
    
  
 
Public methods
    getUnderlying
    
public CharacterStyle getUnderlying ()
    
    
    
  Returns "this" for most CharacterStyles, but for CharacterStyles
 that were generated by wrap(CharacterStyle), returns the underlying
 CharacterStyle.
    
 
    updateDrawState
    
public abstract void updateDrawState (TextPaint tp)
    
    
    
  
    
 
    wrap
    
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.
    
    | Parameters | 
|---|
      
        | cs | CharacterStyle | 
    
    
 
 
 
  
  
    
  
 
  
    
      
      
    
    
      
    
    
  
       
    
    
      
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-02-10 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[]]