Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White space when using Immersive Full-Screen Mode in android [duplicate]

I use 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 run my app, a white space shows instead of notification and bottom bar.

I think I have a mistake in my 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 any mistake?

update : I test with KitKat.

like image 973
hassan moradnezhad Avatar asked Jul 31 '17 21:07

hassan moradnezhad


People also ask

What is immersive mode in Android?

Some content is best experienced fullscreen without any indicators on the status bar or the navigation bar. Some examples are videos, games, image galleries, books, and slides in a presentation. This is referred to as immersive mode.

How do I get my phone off full screen mode?

From Settings, tap Display, and then tap Full screen apps.


1 Answers

The white color is due to the background set in the RelativeLayout. To remove the bottom white bar, simply remove this tag from RelativeLayout:

  android:fitsSystemWindows="true"

It gets added when the app is created and adds a general padding to the layout to ensure that contents don't overlap the system windows.

like image 85
Abhi Avatar answered Nov 12 '22 18:11

Abhi