I am trying to make an activity that is completely fullscreen in landscape, and have the status bar and navigation buttons visible in portrait.
I have to be able to do this programatically.
This is how I tried make the app go fullscreen.
private void hideNavigationAndStatusBars(){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // these work only on API 21 and above
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
The problems are the following :
On some devices, I get a blank portion on the top of the screen, that is equal to the height of the status bar, even though the status bar is not showing
On other devices, the activity fills the whole screen, but when I click anything, the status bar and navigation bar appear, they resize the layout and it looks very ugly
What I am trying to achieve:
The activity should fill the whole screen in landscape, positioned behind the status bar and navigation bar, if they appear
When the user clicks on the screen, he/she should interact with the screen. Instead the first click displays the status and navigation bars and the interaction is possible only after this
The status bar should only appear when the user drags from the top
to hide action bar call getActionBar().hide() method.
And to make activity full screen call
this method
requestFeature(Window.FeatureNo_Title)
Use immersive mode and system ui stable flag to achieve this. For more information please refer the document in developer site.
Related
Android
Hello.
I want to adjust the size of devices resolution and splash image in the splash screen.
I did try to apply png file to 9patch.
But I made gap between device to navigation bar.
And I'd try, try, try, I have reached this point.
I don't know how control navigation bar and button.
Please please please, teach me how hide navigation bar in the splash screen or how change the color in navigation bar's buttons.
Kindly review and give feedback.
It would be better to have some code so we can suggest what could be improved.
But here is some suggestions from android developer documentation.
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);
read more here on how to hide navigation bar.
Link
I wrote an app that is composed by a full screen webkit object. So, as soon as the activity starts, i set these flags:
SYSTEM_UI_FLAG_LAYOUT_STABLE
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
SYSTEM_UI_FLAG_HIDE_NAVIGATION
SYSTEM_UI_FLAG_FULLSCREEN
SYSTEM_UI_FLAG_IMMERSIVE
Problem is that when i swap down from the top border of the screen, status bar and navigation bar becomes visible (and this is ok, so you can close the app if you need it). Problem is that, after a few seconds, status bar goes away while navigation bar doesn't. It stucks there. Is there a flag I am missing? Or is there any hook I can use to detect when the status bar hides and then set back the flags?
I have one View which I want to put in the whole screen, ie.. by making the status bar (top bar) and navigation bar (bottom bar) translusent and putting some portion of the view behind it. I tried the using the flags :
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
But they just hide them, and on touching these flags get cleared. It is understandable that android OS wants user to always have the navigation bar and that is why it is showing them again, but isn't there a way to just show our view behind the navigation bar.
I manage to put my layout behind the status bar using
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
But still, how can I put my view behind Navigation bar too.
Also I am developing the app for API level 14 and above, so I cant use, IMMERSIVE_STICKY or IMMERSIVE mode. Any Suggestions will be appreciated.
I want to hide Bottom Option Bar in Android. I don't know whether we call it Option Bar it or not.
Please check it out Image below : Tell me if we call it something else. It is in bottom.
Now, I want to hide it. How to do it ?
It's called navigation bar, the reason for it only having the options button is probably because your device has hardware buttons for home and back, that's why it looks like an options button only bar.
Refer to the docs for hiding it, although it will only work for versions supporting it.
For 4.0+
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);
I want to write an app with overlay status bar and system button bar like below picture. I tried
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_FULLSCREEN;
but it when status bar and system button bar appear, they come with two black bars. Can anyone help me?
Image
Documentation:
The figure below illustrates the different "immersive mode" states:
Situation 4 - Sticky flag This is the UI you see if you use the IMMERSIVE_STICKY flag, and the user swipes to display the system bars. Semi-transparent
bars temporarily appear and then hide again. The act of swiping
doesn't clear any flags, nor does it trigger your system UI visibility
change listeners, because the transient appearance of the system bars
isn't considered a UI visibility change.
https://developer.android.com/training/system-ui/immersive.html