androidx.window.core.layout


Classes

WindowHeightSizeClass

This class is deprecated. WindowHeightSizeClass will not be developed further, use WindowSizeClass instead.

Cmn
WindowSizeClass

WindowSizeClass represents breakpoints for a viewport.

Cmn
WindowWidthSizeClass

This class is deprecated. WindowWidthSizeClass will not be developed further, use WindowSizeClass instead.

Cmn

Top-level functions summary

Set<WindowSizeClass>
createGridWindowSizeClassSet(
    minWidthDpBreakPoints: Set<Int>,
    minHeightDpBreakPoints: Set<Int>
)

Creates a new set of breakpoints by taking the cross product of minWidthDpBreakPoints and minHeightDpBreakPoints.

Cmn

Extension functions summary

Set<WindowSizeClass>
Set<WindowSizeClass>.addHeightDpBreakpoints(
    minHeightDpBreakPoints: Set<Int>
)

Creates a new Set that contains the original WindowSizeClass values in addition to new elements where the width is from the original set and the height is from minHeightDpBreakPoints.

Cmn
WindowSizeClass
Set<WindowSizeClass>.computeWindowSizeClass(
    widthDp: Float,
    heightDp: Float
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp).

Cmn
WindowSizeClass

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp).

Cmn
WindowSizeClass
Set<WindowSizeClass>.computeWindowSizeClassPreferHeight(
    widthDp: Int,
    heightDp: Int
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp).

Cmn

Top-level functions

createGridWindowSizeClassSet

fun createGridWindowSizeClassSet(
    minWidthDpBreakPoints: Set<Int>,
    minHeightDpBreakPoints: Set<Int>
): Set<WindowSizeClass>

Creates a new set of breakpoints by taking the cross product of minWidthDpBreakPoints and minHeightDpBreakPoints. For example, if the width set is {10, 20} and the height set is { 100, 200 } then the resulting set will be { (10, 100), (10, 200), (20, 100), (20, 200) }.

Parameters
minWidthDpBreakPoints: Set<Int>

the width breakpoints in DP to construct the WindowSizeClass

minHeightDpBreakPoints: Set<Int>

the height breakpoints in DP to construct the WindowSizeClass.

Returns
Set<WindowSizeClass>

a Set containing the breakpoints using a grid style

Extension functions

addHeightDpBreakpoints

fun Set<WindowSizeClass>.addHeightDpBreakpoints(
    minHeightDpBreakPoints: Set<Int>
): Set<WindowSizeClass>

Creates a new Set that contains the original WindowSizeClass values in addition to new elements where the width is from the original set and the height is from minHeightDpBreakPoints. Note this method does not fill in any gaps in the original set. For example if the original set was { (10, 10), (20, 20) } and the height set is { 30 } the new set will be { (10, 10), (20, 20), (10, 30), (20, 30) }. To maintain a grid set the source set must also be a grid set.

Parameters
minHeightDpBreakPoints: Set<Int>

the height breakpoints in DP to construct the WindowSizeClass.

Returns
Set<WindowSizeClass>

a new Set that contains (minWidthDp, minHeightDp) for each pair possible taking the * height breakpoint from minHeightDpBreakPoints and the width breakpoint from this.

computeWindowSizeClass

fun Set<WindowSizeClass>.computeWindowSizeClass(
    widthDp: Float,
    heightDp: Float
): WindowSizeClass

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp). This method prefers width and uses max height to break ties. If there is no match a default of WindowSizeClass(0,0) is returned. Examples: Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300.5f heightDp: 800.5f Output: WindowSizeClass(300, 600) Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300 heightDp: 400 Output: WindowSizeClass(300, 300). This is an overload that truncates the floats to integers.

Parameters
widthDp: Float

the width of the window to match a WindowSizeClass to.

heightDp: Float

the height of the window to match a WindowSizeClass to.

computeWindowSizeClass

fun Set<WindowSizeClass>.computeWindowSizeClass(widthDp: Int, heightDp: Int): WindowSizeClass

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp). This method prefers width and uses max height to break ties. If there is no match a default of WindowSizeClass(0,0) is returned. Examples: Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300 heightDp: 800 Output: WindowSizeClass(300, 600) Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300 heightDp: 400 Output: WindowSizeClass(300, 300)

Parameters
widthDp: Int

the width of the window to match a WindowSizeClass to.

heightDp: Int

the height of the window to match a WindowSizeClass to.

computeWindowSizeClassPreferHeight

fun Set<WindowSizeClass>.computeWindowSizeClassPreferHeight(
    widthDp: Int,
    heightDp: Int
): WindowSizeClass

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp). This method prefers height and uses max width to break ties. If there is no match a default of WindowSizeClass(0,0) is returned. Examples: Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(600, 300) widthDp: 800 heightDp: 300 Output: WindowSizeClass(600, 300) Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(600, 300) widthDp: 400 heightDp: 300 Output: WindowSizeClass(300, 300)

Parameters
widthDp: Int

the width of the window to match a WindowSizeClass to.

heightDp: Int

the height of the window to match a WindowSizeClass to.