Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do I need to use layoutInDisplayCutoutMode?

Android added a way to deal with devices that have a notch/cutout at the top of the screen. (See Android and Xamarin.Android.) But as far as I can tell, Android automatically takes care of lowering the views so that they aren't obscured by the notch, so why do we need this new addition?

I tested my Android app on the emulator of a device with a notch and the app automatically goes below the notch without the need to specify layoutInDisplayCutoutMode as LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER.

So my question is, when would I need to use LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER?

In Xamarin that would be:

Window.Attributes.LayoutInDisplayCutoutMode = Android.Views.LayoutInDisplayCutoutMode.Never;

I'm running this on the Android Emulator through Visual Studio on a Windows computer. The emulator is emulating a Pixel 3 XL with Android Pie 9.0 (API 28). The app is an Android app created with Xamarin.Forms.

like image 687
ispiro Avatar asked Oct 17 '25 08:10

ispiro


1 Answers

When you are creating a view, which uses full screen for showing content at that time notch display sometime hide/cut your top content.

To prevent this android provides support for this above android pie.

Refer to this document. https://source.android.com/devices/tech/display/display-cutouts

like image 193
Rushabh Shah Avatar answered Oct 19 '25 22:10

Rushabh Shah