BaselineShift

@Immutable data class BaselineShift
kotlin.Any
   ↳ androidx.ui.text.style.BaselineShift

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

Summary

Public constructors

<init>(multiplier: Float)

import androidx.ui.core.Span
import androidx.ui.core.Text
import androidx.ui.text.TextStyle

Text {
    Span(text = "Hello", style = TextStyle(fontSize = 20.sp)) {
        Span(
            text = "superscript",
            style = TextStyle(
                baselineShift = BaselineShift.Superscript,
                fontSize = 16.sp
            )
        ) {
            Span(
                text = "subscript",
                style = TextStyle(
                    baselineShift = BaselineShift.Subscript,
                    fontSize = 16.sp
                )
            )
        }
    }
}

Properties

Float

shift the baseline by multiplier * (baseline - ascent)

Companion properties

BaselineShift

Default baseline shift for subscript

BaselineShift

Default baseline shift for superscript.

Public constructors

<init>

BaselineShift(multiplier: Float)
import androidx.ui.core.Span
import androidx.ui.core.Text
import androidx.ui.text.TextStyle

Text {
    Span(text = "Hello", style = TextStyle(fontSize = 20.sp)) {
        Span(
            text = "superscript",
            style = TextStyle(
                baselineShift = BaselineShift.Superscript,
                fontSize = 16.sp
            )
        ) {
            Span(
                text = "subscript",
                style = TextStyle(
                    baselineShift = BaselineShift.Subscript,
                    fontSize = 16.sp
                )
            )
        }
    }
}
import androidx.ui.core.Text
import androidx.ui.text.AnnotatedString
import androidx.ui.text.TextStyle
import androidx.ui.text.withStyle

val annotatedString = AnnotatedString {
    append("Text ")
    withStyle(TextStyle(baselineShift = BaselineShift.Superscript)) {
        append("Demo")
    }
}
Text(text = annotatedString)
Parameters
multiplier: Float shift the baseline by multiplier * (baseline - ascent)

Properties

multiplier

val multiplier: Float

shift the baseline by multiplier * (baseline - ascent)

Companion properties

Subscript

val Subscript: BaselineShift

Default baseline shift for subscript

Superscript

val Superscript: BaselineShift

Default baseline shift for superscript.