Package icyllis.modernui.text.style

# Class ForegroundColorSpan

java.lang.Object
icyllis.modernui.text.style.CharacterStyle
icyllis.modernui.text.style.ForegroundColorSpan

All Implemented Interfaces:
  `ParcelableSpan`, `UpdateAppearance`, `Parcelable`

public class ForegroundColorSpan extends CharacterStyle implements UpdateAppearance, ParcelableSpan
Changes the color of the text to which the span is attached.

For example, to set a green text color you would create a `SpannableString` based on the text and set the span.

     SpannableString string = new SpannableString("Text with a foreground color span");
     string.setSpan(new ForegroundColorSpan(color), 12, 28, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface icyllis.modernui.util.Parcelable

  `Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>, Parcelable.WriteFlags`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ForegroundColorSpan(int color)`
  Creates a `ForegroundColorSpan` from a color integer.
  `ForegroundColorSpan(Parcel src)`
  Creates a `ForegroundColorSpan` from a parcel.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getForegroundColor()`
  `int`
  `getSpanTypeId()`
  Return a special type identifier for this span class.
  `void`
  `updateDrawState(TextPaint paint)`
  Updates the color of the TextPaint to the foreground color.
  `void`
  `writeToParcel(Parcel dest, int flags)`
  The subclass implements the method to flatten its contents by calling the methods of `Parcel` for its primitive values.

  ### Methods inherited from class icyllis.modernui.text.style.CharacterStyle

  `getUnderlying, wrap`

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### ForegroundColorSpan

    public ForegroundColorSpan(@ColorInt int color)
    Creates a `ForegroundColorSpan` from a color integer.
    Parameters:
      `color` - color integer that defines the text color

  - ### ForegroundColorSpan

    public ForegroundColorSpan(@NonNull Parcel src)
    Creates a `ForegroundColorSpan` from a parcel.

- ## Method Details

  - ### getSpanTypeId

    public int getSpanTypeId()
    Description copied from interface: `ParcelableSpan`
    Return a special type identifier for this span class.
    Specified by:
      `getSpanTypeId` in interface `ParcelableSpan`

  - ### writeToParcel

    public void writeToParcel(@NonNull Parcel dest, int flags)
    Description copied from interface: `Parcelable`
    The subclass implements the method to flatten its contents by calling the methods of `Parcel` for its primitive values.
    Specified by:
      `writeToParcel` in interface `Parcelable`
    Parameters:
      `dest` - the parcel to write the object's data to
      `flags` - the flags about how the object should be written

  - ### getForegroundColor

    @ColorInt public int getForegroundColor()
    Returns:
      the foreground color of this span.
    See Also:
      - `ForegroundColorSpan(int)`

  - ### updateDrawState

    public void updateDrawState(@NonNull TextPaint paint)
    Updates the color of the TextPaint to the foreground color.
    Specified by:
      `updateDrawState` in class `CharacterStyle`