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

1

7

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.

Juliannajulianne answered 31/7, 2017 at 21:17 Comment(0)
L
13

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.

Lute answered 1/8, 2017 at 1:43 Comment(5)
I think it is android:fitsSystemWindows="true", see the s in fits.Kerek
@RakeshYadav Thanks for the correction, didn't notice that!Lute
@Lute but when I remove this and exiting full screen mode. status bar got overlapping toolbarAntagonism
@Antagonism I don't understand your question completely. When you exit the full screen mode, isn't it expected behaviour that the top status bar overlaps the toolbar? Please explain your issue further.Lute
@Lute overlapping means status bar is overlapping over some part of toolbar.Antagonism

© 2022 - 2024 — McMap. All rights reserved.