kotlinandroid-jetpack-composeandroid-windowmanagerandroid-cutout

How to handle cutout area by compose?


I'm a Android development beginner . How to handle cutout area by compose? As far as I know... WindowManager doesn't provide information about cutout area. and LayoutInDisplayCutoutMode can be set in xml file. I ask for your advice, please.


Solution

  • In Compose 1.2.* you can get it like this:

    // get value:
    WindowInsets.displayCutout
    
    // apply padding modifier:
    Modifier.displayCutoutPadding() 
    

    In earlier versions you can use Accompanist Insets library:

    // get value:
    LocalWindowInsets.current.displayCutout
    
    // apply padding modifier:
    Modifier.cutoutPadding()