The second Android 11 Developer Preview is now available, test it out and share your feedback.

SpanStyle

@Immutable data class SpanStyle
kotlin.Any
   ↳ androidx.ui.text.SpanStyle

Styling configuration for a text span. This configuration only allows character level styling, in order to set paragraph level styling such as line height, or text alignment please see ParagraphStyle.


//Unresolved: androidx.ui.text.samples.SpanStyleSample

//Unresolved: androidx.ui.text.samples.AnnotatedStringBuilderSample

Summary

Public constructors

<init>(color: Color? = null, fontSize: TextUnit = TextUnit.Inherit, fontWeight: FontWeight? = null, fontStyle: FontStyle? = null, fontSynthesis: FontSynthesis? = null, fontFamily: FontFamily? = null, fontFeatureSettings: String? = null, letterSpacing: TextUnit = TextUnit.Inherit, baselineShift: BaselineShift? = null, textGeometricTransform: TextGeometricTransform? = null, localeList: LocaleList? = null, background: Color? = null, textDecoration: TextDecoration? = null, shadow: Shadow? = null)

Styling configuration for a text span.

Public methods

SpanStyle
merge(other: SpanStyle? = null)

Returns a new span style that is a combination of this style and the given other style.

Properties

Color?

The background color for the text.

BaselineShift?

The amount by which the text is shifted up from the current baseline.

Color?

The text color.

FontFamily?

The font family to be used when rendering the text.

String?

The advanced typography settings provided by font.

TextUnit

The size of glyphs (in logical pixels) to use when painting the text.

FontStyle?

The typeface variant to use when drawing the letters (e.

FontSynthesis?

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided custom font family.

FontWeight?

The typeface thickness to use when painting the text (e.

TextUnit

The amount of space (in em) to add between each letter.

LocaleList?

The locale list used to select region-specific glyphs.

Shadow?

The shadow effect applied on the text.

TextDecoration?

The decorations to paint on the text (e.

TextGeometricTransform?

The geometric transformation applied the text.

Public constructors

<init>

SpanStyle(
    color: Color? = null,
    fontSize: TextUnit = TextUnit.Inherit,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Inherit,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color? = null,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null)

Styling configuration for a text span. This configuration only allows character level styling, in order to set paragraph level styling such as line height, or text alignment please see ParagraphStyle.


//Unresolved: androidx.ui.text.samples.SpanStyleSample

//Unresolved: androidx.ui.text.samples.AnnotatedStringBuilderSample
Parameters
color: Color? = null The text color.
fontSize: TextUnit = TextUnit.Inherit The size of glyphs (in logical pixels) to use when painting the text. This may be TextUnit.Inherit for inheriting from another SpanStyle.
fontWeight: FontWeight? = null The typeface thickness to use when painting the text (e.g., bold).
fontStyle: FontStyle? = null The typeface variant to use when drawing the letters (e.g., italic).
fontSynthesis: FontSynthesis? = null Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided custom font family.
fontFamily: FontFamily? = null The font family to be used when rendering the text.
fontFeatureSettings: String? = null The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
letterSpacing: TextUnit = TextUnit.Inherit The amount of space (in em) to add between each letter.
baselineShift: BaselineShift? = null The amount by which the text is shifted up from the current baseline.
textGeometricTransform: TextGeometricTransform? = null The geometric transformation applied the text.
localeList: LocaleList? = null The locale list used to select region-specific glyphs.
background: Color? = null The background color for the text.
textDecoration: TextDecoration? = null The decorations to paint on the text (e.g., an underline).
shadow: Shadow? = null The shadow effect applied on the text.

Public methods

merge

fun merge(other: SpanStyle? = null): SpanStyle

Returns a new span style that is a combination of this style and the given other style.

other span style's null or inherit properties are replaced with the non-null properties of this span style. Another way to think of it is that the "missing" properties of the other style are filled by the properties of this style.

If the given span style is null, returns this span style.

Properties

background

val background: Color?

The background color for the text.

baselineShift

val baselineShift: BaselineShift?

The amount by which the text is shifted up from the current baseline.

color

val color: Color?

The text color.

fontFamily

val fontFamily: FontFamily?

The font family to be used when rendering the text.

fontFeatureSettings

val fontFeatureSettings: String?

The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop

fontSize

val fontSize: TextUnit

The size of glyphs (in logical pixels) to use when painting the text. This may be TextUnit.Inherit for inheriting from another SpanStyle.

fontStyle

val fontStyle: FontStyle?

The typeface variant to use when drawing the letters (e.g., italic).

fontSynthesis

val fontSynthesis: FontSynthesis?

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided custom font family.

fontWeight

val fontWeight: FontWeight?

The typeface thickness to use when painting the text (e.g., bold).

letterSpacing

val letterSpacing: TextUnit

The amount of space (in em) to add between each letter.

localeList

val localeList: LocaleList?

The locale list used to select region-specific glyphs.

shadow

val shadow: Shadow?

The shadow effect applied on the text.

textDecoration

val textDecoration: TextDecoration?

The decorations to paint on the text (e.g., an underline).

textGeometricTransform

val textGeometricTransform: TextGeometricTransform?

The geometric transformation applied the text.