1

I am developing an application that needs to be on full screen mode.

enter image description here

I tried to use this code in my manifest,

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

but nothing happened and still the button bar (such as Home, Back and Recent Task App) was there. I need to hide them in order to totally have a full screen. Please help me with this. Thank you.

androidBoomer
  • 3,357
  • 6
  • 32
  • 42

4 Answers4

5
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

see developer docs

from API 19 later, you can use SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN
              | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);

see docs here

bladefury
  • 825
  • 6
  • 16
  • @androidBoomer yes, with this approach, touching anywhere on the screen causes the navigation bar (and status bar) to reappear and remain visible. The user interaction causes the flags to be be cleared. – bladefury Jan 20 '14 at 02:56
  • This is standard practice. User interaction will cause the flags to be cleared in order to enable navigation. –  Jan 20 '14 at 03:05
  • So what will I do in order to making it the flags not to be cleared? – androidBoomer Jan 20 '14 at 03:08
  • @androidBoomer you can't, but you can reset the flag after a certain time – bladefury Jan 20 '14 at 03:11
1

Try to write this code before setContentView(R.layout.MainActivity);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

This code work to me

A.Wie
  • 489
  • 3
  • 6
0

@bladefury has a good answer, but you may want to look into this as well...

You're also describing a new feature in 4.4 KitKat called Immersive Mode. Please note that you need API 19 to test this on.

Check out the developer documents

0

After a lot of research, I finally figure it out and make my activity in full screen mode.

getWindow().getDecorView().setSystemUiVisibility(8);
androidBoomer
  • 3,357
  • 6
  • 32
  • 42