DensityScope

interface DensityScope
androidx.ui.core.DensityScope

Used to add density resolution logic within a receiver scope.

Summary

Public methods

open Dp

Convert Sp to Dp.

open Dp

Convert Px to Dp.

open Dp

Convert IntPx to Dp.

open Dp

Convert a Float pixel value to a Dp

open Dp

Convert a Int pixel value to a Dp

open IntPx

Convert Dp to IntPx by rounding

open IntPx

Convert Sp to IntPx by rounding

open Px

Convert Dp to Px.

open Px

Convert Sp to Px.

open PxSize

Convert a Size to a PxSize.

open Rect

Convert a Bounds to a Rect.

open TextUnit

Convert Dp to Sp.

open TextUnit

Convert Px to Sp.

open TextUnit

Convert IntPx to Sp.

open TextUnit

Convert a Float pixel value to a Sp

open TextUnit

Convert a Int pixel value to a Sp

Extension functions

From androidx.ui.layout
Constraints

Creates the Constraints corresponding to the current DpConstraints.

DpConstraints

Creates the DpConstraints corresponding to the current Constraints.

Properties

abstract Density

A Density object.

Public methods

toDp

open fun TextUnit.toDp(): Dp

Convert Sp to Dp.

Exceptions
ArithmeticException if TextUnit other than SP unit is specified.

toDp

open fun Px.toDp(): Dp

Convert Px to Dp.

toDp

open fun IntPx.toDp(): Dp

Convert IntPx to Dp.

toDp

open fun Float.toDp(): Dp

Convert a Float pixel value to a Dp

toDp

open fun Int.toDp(): Dp

Convert a Int pixel value to a Dp

toIntPx

open fun Dp.toIntPx(): IntPx

Convert Dp to IntPx by rounding

toIntPx

open fun TextUnit.toIntPx(): IntPx

Convert Sp to IntPx by rounding

toPx

open fun Dp.toPx(): Px

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

toPx

open fun TextUnit.toPx(): Px

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

Exceptions
ArithmeticException if TextUnit other than SP unit is specified.

toPx

open fun Size.toPx(): PxSize

Convert a Size to a PxSize.

toRect

open fun Bounds.toRect(): Rect

Convert a Bounds to a Rect.

toSp

open fun Dp.toSp(): TextUnit

Convert Dp to Sp. Sp is used for font size, etc.

toSp

open fun Px.toSp(): TextUnit

Convert Px to Sp.

toSp

open fun IntPx.toSp(): TextUnit

Convert IntPx to Sp.

toSp

open fun Float.toSp(): TextUnit

Convert a Float pixel value to a Sp

toSp

open fun Int.toSp(): TextUnit

Convert a Int pixel value to a Sp

Properties

density

abstract val density: Density

A Density object. Useful if you need to pass it as a param.