Sp

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

Dimension value representing scaled pixels (sp). Font related APIs specify their dimensions such as font size in SP with Sp objects. Sp are normally defined using sp, which can be applied to Int, Double, and Float. val leftMargin = 10.sp val rightMargin = 10f.sp val topMargin = 20.0.sp val bottomMargin = 10.sp Drawing is done in pixels. To retrieve the pixel size of a Dp, use toPx: val lineThicknessPx = lineThickness.toPx(context) toPx is normally needed only for painting operations.

Summary

Public constructors

<init>(value: Float)

Dimension value representing scaled pixels (sp).

Public methods

operator Int
compareTo(other: Sp)

Support comparing Dimensions with comparison operators.

operator Sp
div(other: Float)

Divide a Sp by a scalar.

operator Sp
div(other: Int)

operator Float
div(other: Sp)

Divide by another Sp to get a scalar.

operator Sp
minus(other: Sp)

Subtract a Sp from another one.

operator Sp
plus(other: Sp)

Add two Sps together.

operator Sp
times(other: Float)

Multiply a Sp by a scalar.

operator Sp
times(other: Int)

operator Sp

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

Extension functions

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

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

Sp
Sp.coerceAtMost(maximumValue: Sp)

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

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

Ensures that this value lies in the specified range minimumValue.

Em
Sp.toEm(fontSize: Sp)

Convert a value of Sp to Em.

Properties

Float

Companion properties

Sp

Infinite Sp dimension.

Public constructors

<init>

Sp(value: Float)

Dimension value representing scaled pixels (sp). Font related APIs specify their dimensions such as font size in SP with Sp objects. Sp are normally defined using sp, which can be applied to Int, Double, and Float. val leftMargin = 10.sp val rightMargin = 10f.sp val topMargin = 20.0.sp val bottomMargin = 10.sp Drawing is done in pixels. To retrieve the pixel size of a Dp, use toPx: val lineThicknessPx = lineThickness.toPx(context) toPx is normally needed only for painting operations.

Public methods

compareTo

inline operator fun compareTo(other: Sp
): Int

Support comparing Dimensions with comparison operators.

div

inline operator fun div(other: Float
): Sp

Divide a Sp by a scalar.

div

inline operator fun div(other: Int
): Sp

div

inline operator fun div(other: Sp
): Float

Divide by another Sp to get a scalar.

minus

inline operator fun minus(other: Sp
): Sp

Subtract a Sp from another one.

plus

inline operator fun plus(other: Sp
): Sp

Add two Sps together.

times

inline operator fun times(other: Float
): Sp

Multiply a Sp by a scalar.

times

inline operator fun times(other: Int
): Sp

unaryMinus

inline operator fun unaryMinus(): Sp

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

Properties

value

val value: Float

Companion properties

Infinity

val Infinity: Sp

Infinite Sp dimension.