Khalil Bhm
Khalil Bhm

Reputation: 398

Keep Navigation Bar hidden

I am writing a fullscreen application, and I need to KEEP the navBar hidden,

I am using View.SYSTEM_UI_FLAG_HIDE_NAVIGATION But the bar will reappear as soon as there is an interaction from the user,

I found some other questions, but none have the answer ... so have anyone succeeded ? Thank you in advance

Upvotes: 0

Views: 1933

Answers (5)

X.J.
X.J.

Reputation: 1

This works for me.

http://www.androiddocs.com/training/system-ui/immersive.html

From the post:

The flags SYSTEM_UI_FLAG_IMMERSIVE and SYSTEM_UI_FLAG_IMMERSIVE_STICKY both provide an immersive experience, but with the differences in behavior described above. Here are examples of when you would use one flag vs. the other:

If you're building a book reader, news reader, or a magazine, use the IMMERSIVE flag in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION. Because users may want to access the action bar and other UI controls somewhat frequently, but not be bothered with any UI elements while flipping through content, IMMERSIVE is a good option for this use case.

If you're building a truly immersive app, where you expect users to interact near the edges of the screen and you don't expect them to need frequent access to the system UI, use the IMMERSIVE_STICKY flag in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION. For example, this approach might be suitable for a game or a drawing app.

If you're building a video player or some other app that requires minimal user interaction, you can probably get by with the lean back approach, available since Android 4.0 (API Level 14). For this type of app, simply using SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION should be sufficient. Don't use the "immersive" flags in this case.

Upvotes: 0

Radu Varga
Radu Varga

Reputation: 2965

Using only View.SYSTEM_UI_FLAG_HIDE_NAVIGATION, the first touch event is consumed by the system, and the navigation bar will reapear.

If you are coding for KitKat(4.4.2) onwards, you can add this code to your onResume() method:

View decorView = getWindow().getDecorView();
    decorView.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
                                  | View.SYSTEM_UI_FLAG_FULLSCREEN
                                  | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

Read more about Immersive Mode: https://developer.android.com/training/system-ui/immersive.html

Upvotes: 0

goodm
goodm

Reputation: 7295

You can't hide completely NavigationBar, it will ALWAYS reappear after user interaction.

Upvotes: 0

Usman Kurd
Usman Kurd

Reputation: 7023

Add the following line under your activity in Manifest File and it will make you r activity full screen

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

Upvotes: 1

cYrixmorten
cYrixmorten

Reputation: 7108

Would be nice if you posted what you have already tried.

I use this to temporarily hide my actionbar:

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    getActionBar().hide();

The code is at the beginning of onCreate

Upvotes: 0

Related Questions