Interface

Density

A density of the screen.

Common
@JvmDefaultWithCompatibility
interface Density : FontScaling

A density of the screen. Used for the conversions between pixels, Dp, Int and TextUnit.

Properties

Common
val density: Float

The logical density of the display. This is a scaling factor for the Dp unit.

Functions

toPx

fun Dp.toPx(): Float

Convert Dp to pixels. Pixels are used to paint to Canvas.


roundToPx

fun Dp.roundToPx(): Int

Convert Dp to Int by rounding


toPx

fun TextUnit.toPx(): Float

Convert Sp to pixels. Pixels are used to paint to Canvas.


roundToPx

fun TextUnit.roundToPx(): Int

Convert Sp to Int by rounding


toDp

fun Int.toDp(): Dp

Convert an Int pixel value to Dp.


toSp

fun Int.toSp(): TextUnit

Convert an Int pixel value to Sp.


toDp

fun Float.toDp(): Dp

Convert a Float pixel value to a Dp


toSp

fun Float.toSp(): TextUnit

Convert a Float pixel value to a Sp


toRect

fun DpRect.toRect(): Rect

Convert a DpRect to a Rect.


toSize

fun DpSize.toSize(): Size

Convert a DpSize to a Size.


toDpSize

fun Size.toDpSize(): DpSize

Convert a Size to a DpSize.