Our N/Angular app is running in full screen mode. When an alert or a dialog is opened the previously hidden status bar reappears. Is there a way to hide the status bar on alerts/dialogs?
Here is the code we use to set to full screen mode:
const View = android.view.View;
const window = androidApp.startActivity.getWindow();
const decorView = window.getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
For anyone wondering, in Native Script Angular wrapping the dialog component with a Page tag and adding [actionBarHidden]="true" resolves the problem if your dialog content is below you Navigation bar on android, and also adds a background on iOS.
Related
I use the code below to enable fullscreen mode:
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
);
At android 5 all is ok, but at android 4.3 status bar (and nav bar) are opened afrer 'click' action on any button, so I need to tap twice.
How to prevent this control from showing on onClick?
Simply add
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen"
in your manifest.
I have a problem hiding navigation bar at the bottom of the screen in android.
Every solution I've tried doesn't work exactly as I want it to work, except one.
Modifying build.prop with new entry 'qemu.hw.mainkeys=1' worked ok, but it disables navigation bar for whole android system.
Is there possibility to disable navigation bar like this only for one app?
Try this:
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);
(Source)
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
Use this code in onCreate(), it will hide status bar and navigation bar until users swipe down from top of the screen
so i'm writing an app in which i would like the navigation bar in a specific
activity to be hidden...and i managed to do so...but my problem is when the
user scrolls down the notification bar...when that happens...the navigation bar
re-appears...how can i solve this problem?
final int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN;
//View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
when the user scrolls down the notification bar...when that happens...the navigation bar re-appears
I think this behavior is normal and intended as UI design of Android.
Whenever a user swipes-down upper edge or swipes-up bottom edge of screen, both system bar and navigation bar re-appear. Then after a few seconds, they are both disappear again. So as to the user can access system bar or navigation bar whenever they want even if screen is in immersive mode.
can i do anything to disable this? or maybe only hide it
No, generally (without root access) you can't. Only you can do is to hide it. Please refer to these StackOverflow Q&As: Permanently hide navigation bar on activity; Hide System Bar in Tablets.
I tried setting systemUIView(View.GONE) and use Immersive Full-Screen Mode. But users can always get the naviagtion bar back by touching the bottom of the screen. The apps i mentioned above are able to hide it without root or setting default launcher.
Okay, I found a solution finally and here is how it's done:
Use SYSTEM_UI_FLAG_IMMERSIVE_STICKY to hide the navigation bar as follow, you may put the code inside onResume of your activity
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
Then, add a system error window using WindowManger and overlay it on top of everything
you can put this unescapable view anywhere you like, but if you want to do it while users locked the screen, add this flag:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
Et voilà
Well I've never achieved this but it seems that you will need to set some other flags to get this kind of view :
When you use the SYSTEM_UI_FLAG_IMMERSIVE flag, it hides the system bars based on what other UI flags you have set (SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_FULLSCREEN, or both). When the user swipes inward in a system bars region, the system bars reappear and remain visible.
Here is a snippet that you can use to set these flags :
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
For more information go check Using Immersive Full-screen Mode from the android developer website.
Hope this help.
I've followed this thread to hide Navigation bar:
Hide ICS back home task switcher buttons
Works fine when the Activity starts, but whenever I press anywhere on the screen the Navigation bar appears again. I've tried this on an empty Activity without any "views" except the Content View.
How can I hide it throughout the duration of my Activity without having to add some kind of Timer or a Thread to just hide it every millisecond?
It would be great to gain some extra screen size or be able to customize my own Navigation Bar throughout my App.
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
else if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB )
getWindow().getDecorView().setSystemUiVisibility( View.STATUS_BAR_HIDDEN );
This is a problem that came in a long time when we need to show som content in full screen, bumped the difficulty in being able to hide the status bar on some versions of Android:
Finally Google’s latest Android OS, KitKat, introduces a decent user-friendly tool that gives us ownership of that last bit of screen.
Using Immersive Full-Screen Mode see more in : https://developer.android.com/training/system-ui/immersive.html
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
Here's how this has been a thorn in : http://blog.grio.com/2014/02/androids-hiding-of-the-system-bar-fixed.html