lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

TextAppearanceSpan

public class TextAppearanceSpan
extends MetricAffectingSpan implements ParcelableSpan

java.lang.Object
   ↳ android.text.style.CharacterStyle
     ↳ android.text.style.MetricAffectingSpan
       ↳ android.text.style.TextAppearanceSpan


Sets the text color, size, style, and typeface to match a TextAppearance resource.

Summary

Inherited constants

Public constructors

TextAppearanceSpan(Context context, int appearance)

Uses the specified TextAppearance resource to determine the text appearance.

TextAppearanceSpan(Context context, int appearance, int colorList)

Uses the specified TextAppearance resource to determine the text appearance, and the specified text color resource to determine the color.

TextAppearanceSpan(String family, int style, int size, ColorStateList color, ColorStateList linkColor)

Makes text be drawn with the specified typeface, size, style, and colors.

TextAppearanceSpan(Parcel src)

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

String getFamily()

Returns the typeface family specified by this span, or null if it does not specify one.

ColorStateList getLinkTextColor()

Returns the link color specified by this span, or null if it does not specify one.

int getSpanTypeId()

Return a special type identifier for this span class.

ColorStateList getTextColor()

Returns the text color specified by this span, or null if it does not specify one.

int getTextSize()

Returns the text size specified by this span, or -1 if it does not specify one.

int getTextStyle()

Returns the text style specified by this span, or 0 if it does not specify one.

void updateDrawState(TextPaint ds)
void updateMeasureState(TextPaint ds)

Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Public constructors

TextAppearanceSpan

added in API level 1
public TextAppearanceSpan (Context context, 
                int appearance)

Uses the specified TextAppearance resource to determine the text appearance. The appearance should be, for example, android.R.style.TextAppearance_Small.

Parameters
context Context

appearance int

TextAppearanceSpan

added in API level 1
public TextAppearanceSpan (Context context, 
                int appearance, 
                int colorList)

Uses the specified TextAppearance resource to determine the text appearance, and the specified text color resource to determine the color. The appearance should be, for example, android.R.style.TextAppearance_Small, and the colorList should be, for example, android.R.styleable.Theme_textColorPrimary.

Parameters
context Context

appearance int

colorList int

TextAppearanceSpan

added in API level 1
public TextAppearanceSpan (String family, 
                int style, 
                int size, 
                ColorStateList color, 
                ColorStateList linkColor)

Makes text be drawn with the specified typeface, size, style, and colors.

Parameters
family String

style int

size int

color ColorStateList

linkColor ColorStateList

TextAppearanceSpan

added in API level 3
public TextAppearanceSpan (Parcel src)

Parameters
src Parcel

Public methods

describeContents

added in API level 3
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getFamily

added in API level 1
public String getFamily ()

Returns the typeface family specified by this span, or null if it does not specify one.

Returns
String

getLinkTextColor

added in API level 1
public ColorStateList getLinkTextColor ()

Returns the link color specified by this span, or null if it does not specify one.

Returns
ColorStateList

getSpanTypeId

added in API level 3
public int getSpanTypeId ()

Return a special type identifier for this span class.

Returns
int

getTextColor

added in API level 1
public ColorStateList getTextColor ()

Returns the text color specified by this span, or null if it does not specify one.

Returns
ColorStateList

getTextSize

added in API level 1
public int getTextSize ()

Returns the text size specified by this span, or -1 if it does not specify one.

Returns
int

getTextStyle

added in API level 1
public int getTextStyle ()

Returns the text style specified by this span, or 0 if it does not specify one.

Returns
int

updateDrawState

added in API level 1
public void updateDrawState (TextPaint ds)

Parameters
ds TextPaint

updateMeasureState

added in API level 1
public void updateMeasureState (TextPaint ds)

Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters.

Parameters
ds TextPaint: the paint used for drawing the text

writeToParcel

added in API level 3
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.