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.
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.
From Settings, tap Display, and then tap Full screen apps.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With