Em

data class Em
kotlin.Any
   ↳ androidx.ui.core.Em

Dimension value representing Em. 1 Em is defined to be the font size when doing the text layout. For example: Text(style = TextStyle(fontSize = 20.sp, letterSpacing = 0.2.em) The letter spacing rendered equals to 4.sp = 20.sp * 0.2em.

Em is used only in typography related APIs. Since it's a relative length unit, the change of font size will also influence the computed Em length. For example: Text { Span(style = TextStyle(letterSpacing = 0.5.em) { // letter spacing for "Hello" equals to 7.sp Span(text = "Hello", style = TextStyle(fontSize = 14.sp)) // letter spacing for "World" equals to 9.sp Span(text = "World", style = TextStyle(fontSize = 18.sp)) } }

Summary

Public constructors

<init>(value: Float)

Dimension value representing Em.

Public methods

operator Int
compareTo(other: Em)

Support comparing Dimensions with comparison operators.

operator Em
div(other: Float)

Divide a Em by a scalar.

operator Em
div(other: Int)

operator Float
div(other: Em)

Divide by another Em to get a scalar.

operator Em
minus(other: Em)

Subtract a Em from another one.

operator Em
plus(other: Em)

Add two Ems together.

operator Em
times(other: Float)

Multiply a Em by a scalar.

operator Em
times(other: Int)

operator Em

This is the same as multiplying the Em by -1.

Extension functions

From androidx.ui.core
Em
Em.coerceAtLeast(minimumValue: Em)

Ensures that this value is not less than the specified minimumValue.

Em
Em.coerceAtMost(maximumValue: Em)

Ensures that this value is not greater than the specified maximumValue.

Em
Em.coerceIn(minimumValue: Em, maximumValue: Em)

Ensures that this value lies in the specified range minimumValue.

Properties

Float

Public constructors

<init>

Em(value: Float)

Dimension value representing Em. 1 Em is defined to be the font size when doing the text layout. For example: Text(style = TextStyle(fontSize = 20.sp, letterSpacing = 0.2.em) The letter spacing rendered equals to 4.sp = 20.sp * 0.2em.

Em is used only in typography related APIs. Since it's a relative length unit, the change of font size will also influence the computed Em length. For example: Text { Span(style = TextStyle(letterSpacing = 0.5.em) { // letter spacing for "Hello" equals to 7.sp Span(text = "Hello", style = TextStyle(fontSize = 14.sp)) // letter spacing for "World" equals to 9.sp Span(text = "World", style = TextStyle(fontSize = 18.sp)) } }

Public methods

compareTo

inline operator fun compareTo(other: Em
): Int

Support comparing Dimensions with comparison operators.

div

inline operator fun div(other: Float
): Em

Divide a Em by a scalar.

div

inline operator fun div(other: Int
): Em

div

inline operator fun div(other: Em
): Float

Divide by another Em to get a scalar.

minus

inline operator fun minus(other: Em
): Em

Subtract a Em from another one.

plus

inline operator fun plus(other: Em
): Em

Add two Ems together.

times

inline operator fun times(other: Float
): Em

Multiply a Em by a scalar.

times

inline operator fun times(other: Int
): Em

unaryMinus

inline operator fun unaryMinus(): Em

This is the same as multiplying the Em by -1.0.

Properties

value

val value: Float