TextUnit
-
Cmn
value class TextUnit
The unit used for text related dimension value.
This unit can hold either scaled pixels (SP), relative font size (EM) and special unit Unspecified for indicating inheriting from other style or using the default value. It can be created with sp or em. (e.g. 15.sp or 18.em) which can be applied to Int, Double, and Float.
Note that do not store this value in your persistent storage or send to another process since the internal representation may be changed in future.
Summary
Public companion properties |
||
|---|---|---|
TextUnit |
A special |
Cmn
|
Public functions |
||
|---|---|---|
inline operator Int |
Support comparing Dimensions with comparison operators. |
Cmn
|
inline operator TextUnit |
Divide a |
Cmn
|
inline operator TextUnit |
Divide a |
Cmn
|
inline operator TextUnit |
Divide a |
Cmn
|
inline operator TextUnit |
Multiply a |
Cmn
|
inline operator TextUnit |
Multiply a |
Cmn
|
inline operator TextUnit |
Multiply a |
Cmn
|
open String |
toString() |
Cmn
|
inline operator TextUnit |
This is the same as multiplying the |
Cmn
|
Public properties |
||
|---|---|---|
Boolean |
True if this is a EM unit type. |
Cmn
|
Boolean |
True if this is a SP unit type. |
Cmn
|
TextUnitType |
A type information of this TextUnit. |
Cmn
|
Float |
Returns the value of this |
Cmn
|
Extension functions |
||
|---|---|---|
inline TextUnit |
TextUnit.takeOrElse(block: () -> TextUnit)If this |
Cmn
|
Extension properties |
||
|---|---|---|
Boolean |
|
Cmn
|
Boolean |
|
Cmn
|
Public companion properties
Unspecified
val Unspecified: TextUnit
A special TextUnit instance for representing inheriting from parent value.
Notice that performing arithmetic operations on Unspecified may result in an IllegalArgumentException.
Public functions
compareTo
inline operator fun compareTo(other: TextUnit): Int
Support comparing Dimensions with comparison operators.
| Returns | |
|---|---|
Int |
0 if this |
| Throws | |
|---|---|
IllegalArgumentException |
if this |
div
inline operator fun div(other: Double): TextUnit
Divide a TextUnit by a scalar.
This operation works only if the left operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
div
inline operator fun div(other: Float): TextUnit
Divide a TextUnit by a scalar.
This operation works only if the left operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
div
inline operator fun div(other: Int): TextUnit
Divide a TextUnit by a scalar.
This operation works only if the left operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
times
inline operator fun times(other: Double): TextUnit
Multiply a TextUnit by a scalar.
This operation works only if the left operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
times
inline operator fun times(other: Float): TextUnit
Multiply a TextUnit by a scalar.
This operation works only if the left operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
times
inline operator fun times(other: Int): TextUnit
Multiply a TextUnit by a scalar.
This operation works only if the left operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
unaryMinus
inline operator fun unaryMinus(): TextUnit
This is the same as multiplying the TextUnit by -1.0.
This operation works only if the operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.
| Throws | |
|---|---|
IllegalArgumentException |
if this |
Public properties
value
val value: Float
Returns the value of this TextUnit.
For example, the value of 3.sp equals to 3, and value of 5.em equals to 5. The value of TextUnits whose TextUnitType is TextUnitType.Unspecified is undefined.