I'm trying to use the immersive mode introduced in Android 4.4. I use this code to set the visibility and it works exactly how I want it to:
View decorView = getWindow().getDecorView();
int uiOptions = //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_STICKY;
decorView.setSystemUiVisibility(uiOptions);
However, it puts a line on the display. I have a screenshot but cannot post it because this is my first question. I have no idea what it is or how to get rid of it. Can anyone help?
Related
my requirement(security purpose) is when user log into my app he is not allow to
close app
navigate to another app
not allow to change setting
so to fulfilled this requirement i want to
Hide Bottom navigation Bar (or)
disable Bottom navigation bar
i try to hide bottom navigation bar using this code
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION ;
decorView.setSystemUiVisibility(uiOptions);
but when i touch screen again Bottom navigation reappear
This is banking app banking people requesting to do that if there any possibility
do this task or if you have any other solution please give me
It can not be permanently hidden- it would be android security issue
Try this:
View decor_View = getWindow().getDecorView();
int ui_Options = 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;
decor_View.setSystemUiVisibility(ui_Options);
But it need device android OS version is 4.4 or higher.
I want to enable and to disable statusbar and navigation bar in my android app. For this i use next methods:
private void hideSystemUi() {
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);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
private void showSystemUi() {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
where
decorView = getWindow().getDecorView();
It works okay: these methods show and hide statusbar with navigationbar, BUT there is the problem: when statusbar is hide, i can to show it with top-bottom swipe in top part of my screen; similar situation with navigationbar. So , how to resolve this? I want to disable these system view fully, without possibility to show them with swipe. Thanks.
I'm implementing immersive mode using this code:
activity.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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
But the problem is as I scroll the recycler view, the status and navigation bar are shown as an item view reaches the top. It's hard to explain but here's the gif:
https://giphy.com/gifs/xT4uQiBlagrD9ljQqc
Note that as an item view approaches the top, the status bar is shown (only the dark background is shown though). Note also the navigation bar as an item view's bottom reaches the boundary of the navigation bar (notice the gray background at the bottom).
This happens for every item in the recycler view which is really annoying.
It's missing you some UI options like immersive sticky.
Here's my working ui options:
View decorView = getWindow().getDecorView();
int uiOptions = 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;
decorView.setSystemUiVisibility(uiOptions);
How do I make the navigation bar transparent in landscape?
It works in portrait.
My device version is Kitkat(Nexus5)
The Youtube Kids works in KitKat.
I solved this problem.
We cannot set a color to navigation bar in landscape under lollipop.
But we can set transpalent temporarily these version.
You set the flag which is View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY.
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_STICKY);
An app hides the action bar in the following way:
uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
//Hide both the status bar and navigation bar
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
When the screen is touched, the following method is called to show the action bar:
uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(uiOptions);
Everything works as expected except when the overflow menu is opened after the 3-dot is tapped, onMenuOpened of the activity is not called, but the menu is opened normally.
Could anyone shed some light on this?
Possibly this.
The reason that onMenuOpened() and onPanelClosed() are not called is
that Activity's default implementations of those methods will try and
init the framework Action Bar.