androidx.window.core.layout


Classes

WindowHeightSizeClass

A class to represent the height size buckets for a viewport.

Cmn
WindowSizeClass

WindowSizeClass represents breakpoints for a viewport.

Cmn
WindowWidthSizeClass

A class to represent the width size buckets for a viewport.

Cmn

Extension functions summary

Int
@ExperimentalWindowCoreApi
WindowSizeClass.scoreWithinAreaBounds(
    windowWidthDp: Int,
    windowHeightDp: Int
)

A scoring function to calculate how close the area of a WindowSizeClass is to the area of a window without exceeding it.

Cmn
Int

A scoring function to calculate how close the height of a WindowSizeClass is to heightDp without exceeding it.

Cmn
Int

A scoring function to calculate how close the width of a WindowSizeClass is to widthDp without exceeding it.

Cmn
WindowSizeClass?
Set<WindowSizeClass>.widestOrEqualWidthDp(
    windowWidthDp: Int,
    windowHeightDp: Int
)

Calculates which WindowSizeClass has the closest matching windowWidthDp within the given value.

Cmn

Extension functions

scoreWithinAreaBounds

@ExperimentalWindowCoreApi
fun WindowSizeClass.scoreWithinAreaBounds(
    windowWidthDp: Int,
    windowHeightDp: Int
): Int

A scoring function to calculate how close the area of a WindowSizeClass is to the area of a window without exceeding it.

Parameters
windowWidthDp: Int

the width of a window constraint.

windowHeightDp: Int

the height of a window constraint.

Returns
Int

an integer from -1 to Integer.MAX_VALUE where a larger value indicates a better match.

scoreWithinHeightDp

@ExperimentalWindowCoreApi
fun WindowSizeClass.scoreWithinHeightDp(heightDp: Int): Int

A scoring function to calculate how close the height of a WindowSizeClass is to heightDp without exceeding it.

Parameters
heightDp: Int

the height bound to try to match.

Returns
Int

an integer from -1 to Integer.MAX_VALUE where a larger value indicates a better match.

scoreWithinWidthDp

@ExperimentalWindowCoreApi
fun WindowSizeClass.scoreWithinWidthDp(widthDp: Int): Int

A scoring function to calculate how close the width of a WindowSizeClass is to widthDp without exceeding it.

Parameters
widthDp: Int

the width bound to try to match.

Returns
Int

an integer from -1 to Integer.MAX_VALUE where a larger value indicates a better match.

widestOrEqualWidthDp

fun Set<WindowSizeClass>.widestOrEqualWidthDp(
    windowWidthDp: Int,
    windowHeightDp: Int
): WindowSizeClass?

Calculates which WindowSizeClass has the closest matching windowWidthDp within the given value. If there are multiple matches then the tallest WindowSizeClass is selected within the given value.

Parameters
windowWidthDp: Int

the width of the current window in DP to choose a WindowSizeClass.

windowHeightDp: Int

the height of the current window in DP to chose a WindowSizeClass.

Returns
WindowSizeClass?

a WindowSizeClass that has WindowSizeClass.widthDp less than or equal to the windowWidthDp and is the closest to windowWidthDp if possible null otherwise.