Now, the emulator only allows us to add display cutouts that are positioned at the top of the window. In most cases this may not be an issue, as you can see from the screenshot these cutouts do not extend past the status bar — so they’re not overlapping with any of the application content. However, it’s not entirely clear if this will always be the case — device manufacturers may add cutouts areas that are positioned and/or sized differently, meaning that they may extend past this status bar area within our window.

There is now a window layout attribute that allows our application to layout our screen content around the cutouts of the device screen. This is known as layoutInDisplayCutoutMode. We can apply a value to this property by accessing the layout parameters of our content and setting the layoutInDisplayCutoutMode property.

val params = window.attributes

params.layoutInDisplayCutoutMode =

WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS

This property can be set to one of three values:

Default display cutout mode

The first value which we can assign to the new window layout attribute is LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT . This value implies that the current window is allowed to automatically extend into the cutout area of the display, given that the cutout is completely contained within the status bar — meaning that it has to be at the top of the screen and be no taller than the height of the status bar. If this does not hold true then the window will be laid out in way that does involve any overlapping of the window content with the cutout area.

Note: Setting FLAG_FULLSCREEN or SYSTEM_UI_FLAG_FULLSCREEN whilst this default value is being used will remove the ability of the window extending into the cutout area.

Always overlap with cutout

The next value that can be set is LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS . This will mean that the current window is always allowed to extend into the given Display Cutout area, regardless of whether the device is in landscape or portrait mode. If we set this mode, it is our responsibility that no important content is overlapped by the display cutout.

here, the layout containing the video player extends into the area of the cutout, giving us a fully immersive experience.

Never overlap with cutout

The final value that we can set is LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER . This declares that the window is never allowed to overlap it’s content into the area of the display cutout.

You can see here that we have wasted window space at the top of our layout. This is because the layout for the video player was not allowed to extend into the area of the display cutout.