public final class WidthSizeClass


A class to create buckets for the width of a window.

For details on window size classes, see https://developer.android.com/guide/topics/large-screens/support-different-screen-sizes.

Summary

Nested types

public static class WidthSizeClass.Companion

Public fields

static final @NonNull WidthSizeClass

A bucket to represent a compact width window.

static final @NonNull WidthSizeClass

A bucket to represent an expanded width window.

static final @NonNull WidthSizeClass

A bucket to represent a medium width window.

Public methods

static final @NonNull WidthSizeClass
compute(int dpWidth)

Returns a recommended WidthSizeClass for the width of a window given the width in DP.

boolean
equals(Object other)
static final @NonNull WidthSizeClass.Companion.WidthSizeClassEnum

Returns a WidthSizeClassEnum given the WidthSizeClass.

static final int

Returns a recommended width of a window in DP given the WidthSizeClass.

int
@NonNull String

Public fields

COMPACT

public static final @NonNull WidthSizeClass COMPACT

A bucket to represent a compact width window. One use-case is a phone in portrait.

EXPANDED

public static final @NonNull WidthSizeClass EXPANDED

A bucket to represent an expanded width window. One use-case is a desktop app.

MEDIUM

public static final @NonNull WidthSizeClass MEDIUM

A bucket to represent a medium width window. Some use-cases are a phone in landscape or a tablet.

Public methods

compute

public static final @NonNull WidthSizeClass compute(int dpWidth)

Returns a recommended WidthSizeClass for the width of a window given the width in DP.

Parameters
int dpWidth

the width of the window in DP

Returns
@NonNull WidthSizeClass

A recommended size class for the width

Throws
kotlin.IllegalArgumentException

if the width is negative

equals

public boolean equals(Object other)

getEnum

public static final @NonNull WidthSizeClass.Companion.WidthSizeClassEnum getEnum(@NonNull WidthSizeClass sizeClass)

Returns a WidthSizeClassEnum given the WidthSizeClass.

Parameters
@NonNull WidthSizeClass sizeClass

the size class

Returns
@NonNull WidthSizeClass.Companion.WidthSizeClassEnum

the relevant WidthSizeClassEnum

getWidthDpInSizeClass

public static final int getWidthDpInSizeClass(@NonNull WidthSizeClass sizeClass)

Returns a recommended width of a window in DP given the WidthSizeClass.

Parameters
@NonNull WidthSizeClass sizeClass

the size class

Returns
int

A recommended width in DP in this size class

hashCode

public int hashCode()

toString

public @NonNull String toString()