Added in API level 1

TextAppearanceSpan

open class TextAppearanceSpan : MetricAffectingSpan, ParcelableSpan
kotlin.Any
   ↳ android.text.style.CharacterStyle
   ↳ android.text.style.MetricAffectingSpan
   ↳ android.text.style.TextAppearanceSpan

Sets the text appearance using the given TextAppearance attributes. By default TextAppearanceSpan only changes the specified attributes in XML. textColorHighlight, textColorHint, textAllCaps and fallbackLineSpacing are not supported by TextAppearanceSpan. {@see android.widget.TextView#setTextAppearance(int)}

Summary

XML attributes
android:elegantTextHeight Elegant text height, especially for less compacted complex script text.
android:fontFamily Font family (named by string or as a font resource reference) for the text.
android:fontFeatureSettings Font feature settings.
android:fontVariationSettings Font variation settings.
android:letterSpacing Text letter-spacing.
android:shadowColor Place a blurred shadow of text underneath the text, drawn with the specified color.
android:shadowDx Horizontal offset of the text shadow.
android:shadowDy Vertical offset of the text shadow.
android:shadowRadius Blur radius of the text shadow.
android:textColor Text color.
android:textColorLink Color of the links.
android:textFontWeight Weight for the font used in the TextView.
android:textSize Size of the text.
android:textStyle Style (normal, bold, italic, bold|italic) for the text.
android:typeface Typeface (normal, sans, serif, monospace) for the text.
Public constructors
TextAppearanceSpan(context: Context!, appearance: Int)

Uses the specified TextAppearance resource to determine the text appearance.

TextAppearanceSpan(context: Context!, appearance: Int, colorList: Int)

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

TextAppearanceSpan(family: String!, style: Int, size: Int, color: ColorStateList!, linkColor: ColorStateList!)

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

Public methods
open Int

open String!

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

open String?

Returns the font feature settings specified by this span, or null if it does not specify one.

open String?

Returns the font variation settings specified by this span, or null if it does not specify one.

open Float

Returns the value of letter spacing to be added in em unit.

open ColorStateList!

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

open Int

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

open Float

Returns the horizontal offset of the text shadow specified by this span, or 0.0f if it does not specify one.

open Float

Returns the vertical offset of the text shadow specified by this span, or 0.0f if it does not specify one.

open Float

Returns the blur radius of the text shadow specified by this span, or 0.0f if it does not specify one.

open Int

open ColorStateList!

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

open Int

Returns the text font weight specified by this span, or FontStyle.FONT_WEIGHT_UNSPECIFIED if it does not specify one.

open LocaleList?

Returns the android.os.LocaleList specified by this span, or null if it does not specify one.

open Int

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

open Int

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

open Typeface?

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

open Boolean

Returns the value of elegant height metrics flag specified by this span, or false if it does not specify one.

open String

open Unit

open Unit

open Unit
writeToParcel(dest: Parcel, flags: Int)

Inherited functions

XML attributes

android:elegantTextHeight

android:elegantTextHeight
Elegant text height, especially for less compacted complex script text.

May be a boolean value, such as "true" or "false".

android:fontFamily

android:fontFamily
Font family (named by string or as a font resource reference) for the text.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:fontFeatureSettings

android:fontFeatureSettings
Font feature settings.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:fontVariationSettings

android:fontVariationSettings
Font variation settings.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:letterSpacing

android:letterSpacing
Text letter-spacing.

May be a floating point value, such as "1.2".

android:shadowColor

android:shadowColor
Place a blurred shadow of text underneath the text, drawn with the specified color. The text shadow produced does not interact with properties on View that are responsible for real time shadows, elevation and translationZ.

May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".

android:shadowDx

android:shadowDx
Horizontal offset of the text shadow.

May be a floating point value, such as "1.2".

android:shadowDy

android:shadowDy
Vertical offset of the text shadow.

May be a floating point value, such as "1.2".

android:shadowRadius

android:shadowRadius
Blur radius of the text shadow.

May be a floating point value, such as "1.2".

android:textColor

android:textColor
Text color.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".

android:textColorLink
Color of the links.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".

android:textFontWeight

android:textFontWeight
Weight for the font used in the TextView.

May be an integer value, such as "100".

android:textSize

android:textSize
Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp).

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:textStyle

android:textStyle
Style (normal, bold, italic, bold|italic) for the text.

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
bold 1
italic 2
normal 0

android:typeface

android:typeface
Typeface (normal, sans, serif, monospace) for the text.

Must be one of the following constant values.

Constant Value Description
monospace 3
normal 0
sans 1
serif 2

Public constructors

TextAppearanceSpan

Added in API level 1
TextAppearanceSpan(
    context: Context!,
    appearance: Int)

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

TextAppearanceSpan

Added in API level 1
TextAppearanceSpan(
    context: Context!,
    appearance: Int,
    colorList: Int)

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.

TextAppearanceSpan

Added in API level 1
TextAppearanceSpan(
    family: String!,
    style: Int,
    size: Int,
    color: ColorStateList!,
    linkColor: ColorStateList!)

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

TextAppearanceSpan

Added in API level 1
TextAppearanceSpan(src: Parcel!)

Public methods

describeContents

Added in API level 3
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getFamily

Added in API level 1
open fun getFamily(): String!

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

getFontFeatureSettings

Added in API level 29
open fun getFontFeatureSettings(): String?

Returns the font feature settings specified by this span, or null if it does not specify one.

getFontVariationSettings

Added in API level 29
open fun getFontVariationSettings(): String?

Returns the font variation settings specified by this span, or null if it does not specify one.

getLetterSpacing

Added in API level 34
open fun getLetterSpacing(): Float

Returns the value of letter spacing to be added in em unit.

Return
Float a letter spacing amount

getLinkTextColor

Added in API level 1
open fun getLinkTextColor(): ColorStateList!

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

getShadowColor

Added in API level 29
open fun getShadowColor(): Int

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

getShadowDx

Added in API level 29
open fun getShadowDx(): Float

Returns the horizontal offset of the text shadow specified by this span, or 0.0f if it does not specify one.

getShadowDy

Added in API level 29
open fun getShadowDy(): Float

Returns the vertical offset of the text shadow specified by this span, or 0.0f if it does not specify one.

getShadowRadius

Added in API level 29
open fun getShadowRadius(): Float

Returns the blur radius of the text shadow specified by this span, or 0.0f if it does not specify one.

getSpanTypeId

Added in API level 3
open fun getSpanTypeId(): Int

getTextColor

Added in API level 1
open fun getTextColor(): ColorStateList!

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

getTextFontWeight

Added in API level 29
open fun getTextFontWeight(): Int

Returns the text font weight specified by this span, or FontStyle.FONT_WEIGHT_UNSPECIFIED if it does not specify one.

getTextLocales

Added in API level 29
open fun getTextLocales(): LocaleList?

Returns the android.os.LocaleList specified by this span, or null if it does not specify one.

getTextSize

Added in API level 1
open fun getTextSize(): Int

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

getTextStyle

Added in API level 1
open fun getTextStyle(): Int

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

getTypeface

Added in API level 29
open fun getTypeface(): Typeface?

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

isElegantTextHeight

Added in API level 29
open fun isElegantTextHeight(): Boolean

Returns the value of elegant height metrics flag specified by this span, or false if it does not specify one.

toString

Added in API level 1
open fun toString(): String
Return
String a string representation of the object.

updateDrawState

Added in API level 1
open fun updateDrawState(ds: TextPaint!): Unit

updateMeasureState

Added in API level 1
open fun updateMeasureState(ds: TextPaint): Unit
Parameters
textPaint the paint used for drawing the text This value cannot be null.

writeToParcel

Added in API level 3
open fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES