DisplayCutoutCompat

Added in 1.1.0

public final class DisplayCutoutCompat


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

DisplayCutoutCompat instances are immutable.

Summary

Public constructors

DisplayCutoutCompat(
    @Nullable Rect safeInsets,
    @Nullable List<Rect> boundingRects
)

Creates a DisplayCutout instance.

DisplayCutoutCompat(
    @NonNull Insets safeInsets,
    @Nullable Rect boundLeft,
    @Nullable Rect boundTop,
    @Nullable Rect boundRight,
    @Nullable Rect boundBottom,
    @NonNull Insets waterfallInsets
)

Creates a DisplayCutout instance.

Public methods

boolean
@NonNull List<Rect>

Returns a list of Rects, each of which is the bounding rectangle for a non-functional area 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.

@NonNull Insets

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

int
@NonNull String

Public constructors

DisplayCutoutCompat

Added in 1.1.0
public DisplayCutoutCompat(
    @Nullable Rect safeInsets,
    @Nullable List<Rect> boundingRects
)

Creates a DisplayCutout instance.

Parameters
@Nullable Rect safeInsets

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

@Nullable List<Rect> boundingRects

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

DisplayCutoutCompat

Added in 1.5.0
public DisplayCutoutCompat(
    @NonNull Insets safeInsets,
    @Nullable Rect boundLeft,
    @Nullable Rect boundTop,
    @Nullable Rect boundRight,
    @Nullable Rect boundBottom,
    @NonNull Insets waterfallInsets
)

Creates a DisplayCutout instance.

Parameters
@NonNull Insets safeInsets

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

@Nullable Rect boundLeft

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).

@Nullable Rect boundTop

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).

@Nullable Rect boundRight

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).

@Nullable Rect boundBottom

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).

@NonNull Insets waterfallInsets

the insets for the curved areas in waterfall display.

Public methods

equals

public boolean equals(Object o)

getBoundingRects

Added in 1.1.0
public @NonNull List<RectgetBoundingRects()

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
@NonNull List<Rect>

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

getSafeInsetBottom

Added in 1.1.0
public int getSafeInsetBottom()

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

getSafeInsetLeft

Added in 1.1.0
public int getSafeInsetLeft()

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

getSafeInsetRight

Added in 1.1.0
public int getSafeInsetRight()

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

getSafeInsetTop

Added in 1.1.0
public int getSafeInsetTop()

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

getWaterfallInsets

Added in 1.5.0
public @NonNull Insets getWaterfallInsets()

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
@NonNull 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

public int hashCode()

toString

public @NonNull String toString()