DisplayCutoutCompat

Added in 1.1.0

class DisplayCutoutCompat


Represents the area of the display that is not functional for displaying content.

DisplayCutoutCompat instances are immutable.

Summary

Public constructors

DisplayCutoutCompat(safeInsets: Rect?, boundingRects: (Mutable)List<Rect!>?)

Creates a DisplayCutout instance.

DisplayCutoutCompat(
    safeInsets: Insets,
    boundLeft: Rect?,
    boundTop: Rect?,
    boundRight: Rect?,
    boundBottom: Rect?,
    waterfallInsets: Insets
)

Creates a DisplayCutout instance.

DisplayCutoutCompat(
    safeInsets: Insets,
    boundLeft: Rect?,
    boundTop: Rect?,
    boundRight: Rect?,
    boundBottom: Rect?,
    waterfallInsets: Insets,
    cutoutPath: Path?
)

Creates a DisplayCutout instance.

Public functions

Boolean
equals(o: Any!)
(Mutable)List<Rect!>

Returns a list of Rects, each of which is the bounding rectangle for a non-functional area on the display.

Path?

Returns a Path that contains the cutout paths of all sides on the display.

Int

Returns the inset from the bottom which avoids the display cutout in pixels.

Int

Returns the inset from the left which avoids the display cutout in pixels.

Int

Returns the inset from the right which avoids the display cutout in pixels.

Int

Returns the inset from the top which avoids the display cutout in pixels.

Insets

Returns the insets representing the curved areas of a waterfall display.

Int
String

Public constructors

DisplayCutoutCompat

Added in 1.1.0
DisplayCutoutCompat(safeInsets: Rect?, boundingRects: (Mutable)List<Rect!>?)

Creates a DisplayCutout instance.

Parameters
safeInsets: Rect?

the insets from each edge which avoid the display cutout as returned by getSafeInsetTop etc.

boundingRects: (Mutable)List<Rect!>?

the bounding rects of the display cutouts as returned by getBoundingRects ()}.

DisplayCutoutCompat

Added in 1.5.0
DisplayCutoutCompat(
    safeInsets: Insets,
    boundLeft: Rect?,
    boundTop: Rect?,
    boundRight: Rect?,
    boundBottom: Rect?,
    waterfallInsets: Insets
)

Creates a DisplayCutout instance.

Parameters
safeInsets: Insets

the insets from each edge which avoid the display cutout as returned by getSafeInsetTop etc.

boundLeft: Rect?

the left bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

boundTop: Rect?

the top bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

boundRight: Rect?

the right bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

boundBottom: Rect?

the bottom bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

waterfallInsets: Insets

the insets for the curved areas in waterfall display.

DisplayCutoutCompat

Added in 1.15.0
DisplayCutoutCompat(
    safeInsets: Insets,
    boundLeft: Rect?,
    boundTop: Rect?,
    boundRight: Rect?,
    boundBottom: Rect?,
    waterfallInsets: Insets,
    cutoutPath: Path?
)

Creates a DisplayCutout instance.

Parameters
safeInsets: Insets

the insets from each edge which avoid the display cutout as returned by getSafeInsetTop etc.

boundLeft: Rect?

the left bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

boundTop: Rect?

the top bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

boundRight: Rect?

the right bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

boundBottom: Rect?

the bottom bounding rect of the display cutout in pixels. If null is passed, it's treated as an empty rectangle (0,0)-(0,0).

waterfallInsets: Insets

the insets for the curved areas in waterfall display.

cutoutPath: Path?

the path of the display cutout. Specifying a path with this constructor is only supported on API 33 and above, even though a real DisplayCutout can have a cutout path on API 31 and above. On API 32 and below, this path is ignored.

Public functions

equals

fun equals(o: Any!): Boolean

getBoundingRects

Added in 1.1.0
fun getBoundingRects(): (Mutable)List<Rect!>

Returns a list of Rects, each of which is the bounding rectangle for a non-functional area on the display. There will be at most one non-functional area per short edge of the device, and none on the long edges.

Returns
(Mutable)List<Rect!>

a list of bounding Rects, one for each display cutout area.

getCutoutPath

Added in 1.15.0
fun getCutoutPath(): Path?

Returns a Path that contains the cutout paths of all sides on the display. To get a cutout path for one specific side, apps can intersect the Path with the Rect obtained from getBoundingRectLeft(), getBoundingRectTop(), getBoundingRectRight() or getBoundingRectBottom().

Returns
Path?

the path corresponding to the cutout, or null if there is no cutout on the display.

getSafeInsetBottom

Added in 1.1.0
fun getSafeInsetBottom(): Int

Returns the inset from the bottom which avoids the display cutout in pixels.

getSafeInsetLeft

Added in 1.1.0
fun getSafeInsetLeft(): Int

Returns the inset from the left which avoids the display cutout in pixels.

getSafeInsetRight

Added in 1.1.0
fun getSafeInsetRight(): Int

Returns the inset from the right which avoids the display cutout in pixels.

getSafeInsetTop

Added in 1.1.0
fun getSafeInsetTop(): Int

Returns the inset from the top which avoids the display cutout in pixels.

getWaterfallInsets

Added in 1.5.0
fun getWaterfallInsets(): Insets

Returns the insets representing the curved areas of a waterfall display. A waterfall display has curved areas along the edges of the screen. Apps should be careful when showing UI and handling touch input in those insets because the curve may impair legibility and can frequently lead to unintended touch inputs.

Returns
Insets

the insets for the curved areas of a waterfall display in pixels or Insets.NONE if there are no curved areas or they don't overlap with the window.

hashCode

fun hashCode(): Int

toString

fun toString(): String