androidandroid-immersive

How to enable immersive mode on landscape orientation


I'm showing Google Map on my application. I want it to look immersive so I added this line.

        WindowCompat.setDecorFitsSystemWindows(window, true)

There is nothing wrong on portrait mode with this line of code but I want full immersive experience on landscape mode as well. Status bar is not transparent/immersive on landscape mode with only a few devices. It may be because of Android versions. Let me attach screenshot to explain my problem better.

I also added these properties to main theme

<item name="android:navigationBarColor">@android:color/transparent</item>
    
    <item name="android:windowTranslucentStatus">true</item>
    
    <item name="android:windowTranslucentNavigation">true</item>
    
    <item name="android:statusBarColor">@android:color/transparent</item>
    
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    
    <item name="android:windowContentOverlay">@null</item>

Android Version: 10


Solution

  • It is not about Android versions. It is all about cutouts some devices have.

    See. https://developer.android.com/guide/topics/display-cutout

    LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES - Content renders into the cutout area in both portrait and landscape modes.

    When I set the property to main theme it works seemlessly

     <item name="android:windowLayoutInDisplayCutoutMode">
     shortEdges <!-- default, shortEdges, never -->
     </item>