Free space when using Immersive full screen in android

I am using below code to use Immersive full screen mode:

getWindow().getDecorView().setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);

      

But when I launch my app, a space is displayed instead of the notification and bottom bar.

I think I have an error in the XML file. Here is my XML file:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#303030"
    tools:context="programsimple.game.FullscreenActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:background="#eeeeee">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/background"/>

        <Button
            android:layout_width="110dp"
            android:layout_height="70dp"
            android:background="@drawable/button_shape"
            android:layout_centerVertical="true"
            android:id="@+id/btnStartGame"
            android:layout_centerHorizontal="true"
            android:text="شروع"
            android:textSize="25sp"
            android:textColor="#97d2ff"/>

    </RelativeLayout>

</FrameLayout>

      

Does it have a bug?

update : I am testing with KitKat.

+3


source to share


1 answer


The white color is due to the background set to RelativeLayout

. To remove the bottom white stripe, simply remove this tag from RelativeLayout

:

  android:fitsSystemWindows="true"

      



It is added when the application is created and adds a generic addition to the layout so that the content does not overlap system windows.

+5


source







All Articles