I'm trying to create an immersive full screen app. The issue is, when I type something in an edit text and hide the keyboard, a black navigation bar shows up at the bottom of my app permanently. This ends up blocking my elements from view and making my app look awful in general.
I've tried searching for a solution but nothing I find seems to work or I'm possibly not searching for the correct term. I'd prefer if the only type of navigation that showed was overlaid on a swipe up gesture on top of the app instead of becoming part of my app. The code below works great initially to create the full screen immersion I'm looking for but as soon as an EditText is triggered it basically disables.
private void hideSystemUI(){
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().hide();
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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
Related
"windowLightStatusBar" not working?
Android app, 24+ only
One: Set theme to eliminate action bar ..
<style name="FattieTheme" parent="Theme.AppCompat.Light.NoActionBar">
Action bar is gone.
Two: Just after super.onCreate , eliminate the bottom nav bar with exactly these three flags:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
(Aside: after mammoth experimentation it appears to make no difference if you apply that to the window (as shown) or the root element of your xml layout.)
Nav bar is gone. (User can swipe it up; it goes away again after a few seconds.) All good.
Status bar is still there. Status bar is a gray, white writing. All good.
Your layout still begins just below the status bar. All good.
Three: Add this flag
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
You now have four flags.
(Aside: using windowFullscreen in Theme appears to do nothing. So add that flag.)
Naturally set your layout xml to fitsSystemWindows false.
Your layout now starts at the top of the glass - it's correctly behind the (gray) status bar. You can still see the (gray) status bar. All good so far.
Four: Theme, add
<item name="android:statusBarColor">#color/white</item>
it correctly goes pink. The status text is white - you can read it.
so try
<item name="android:statusBarColor">#android:color/transparent</item>
bingo! Your app is behind the status text.
BUT...
the status text is white, you likely can't see it. (Unless your app is dark there.)
How to make the text dark ?!
This is supposed to do it:
<item name="android:windowLightStatusBar">true</item>
But it does not! It does nothing.
Does anyone know how the heck to solve this problem?
Make the status bar text black.
Every ordinary app out there, the browser etc, has black status bar text on white/clear. How to??
My app is set to be fullscreen and immersive mode so the Status bar and Navigation bar are hidden. I wrote a custom spinner to be able to prevent the navigation bar from appearing when the spinner is clicked. This actually works but the main Activity view still gets resized as if the navigation and status bar has shown. The area where they would normally be displayed is just white. It will stay like this until I click something in the spinner or cancel by clicking outside of the spinner. Is there something I can call on the main view to refresh it's layout to remove the white space or prevent it entirely?
When the Activity is loaded I call my hideSystemUI method:
private void hideSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Custom spinner onClickListener resets the view back to the original UI layout. So I do not see the actual navigation bars or status bars, just the white space they would have occupied.
Any ideas?
Thanks!
Hi stackoverflow I'm trying to click on button it is behind on transparent activity and current appear on screen this transparent activity so how it possible can you help me ?
Add this code to the transparent activity (onCreate):
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
I am looking to hide the Sherlock action bar on single tap and show it when user does another single tap thus showing/hiding on alternating single tap.
The code for showing and hiding is:
#Override
public boolean onSingleTapConfirmed(MotionEvent e) {
ActionBar actionBar = getSupportActionBar();
if (actionBar.isShowing()) {
actionBar.hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
} else {
actionBar.show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
return super.onSingleTapConfirmed(e);
}
The above code works fine for me but the problem is the jerk seen by the user when the transition od action and notification bars occurs from shown to hidden and vice versa.
To avoid the jerk, I added the following line in the onCreate method, but it causes the action bar to cover the UI elements when the action bar comes to visible from invisible state.
requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);
Is there any way out by which the jerk is also not there and the action bar is not overlayed on the UI elements when it comes from hidden to visible state?
How about achieving the similar behavior with a sliding menu from top?
you could set roatation to SlidingDrawer and use it
android:rotation="180" // in SlidingDrawer manifest tag.
I understand that SlidingDrawer is deprecated in API 17 but you could always have a custom implementation of this. I'm sure this would be a very smooth implementation for you.
I have a video view and i am hiding the navigation bar when video starts playing, but the view is stretched to the empty part created after the hiding the navigation bar. I want to play the video in full screen behind the navigation bar. So that when i do hide/show navigation bar the stretching and shrinking of video view should be avoided. Any suggestions are appreciated ...
Thanks.
What is it basicallly your navigation bar is it a Preloader,..?
for preloader
you can dismiss it like
pd.dismiss();
use full screen window with flag SYSTEM_UI_FLAG_HIDE_NAVIGATION :
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
reference:
http://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_HIDE_NAVIGATION