I have been looking for a way to re-color the navigation bar while the status bar is fully transparent (not translucent).
Getting the status bar to be completely transparent requires the layout flags to be set to NO_LIMITS but that also makes the navigation bar lose its color. Is there any way to achieve this?
If you do not need the status bar text to be dark, the following works.
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
And change the navigation bar color as #JaviChaquƩs suggest.
You can set this:
<item name="android:navigationBarColor">#color/your_color</item>
<item name="android:statusBarColor">#color/your_color</item>
Related
I'm trying to create an 'immersive mode' in my app, where tapping a button simply hides the status bar (and nav bar, if possible.) But I specifically don't want the whole app to resize itself so that the content moves up to fill the space where the status bar used to be -- I just want that top part of the screen to be filled with the same background colour it had before. Ideally from the user's point of view, the status bar notification icons / time / battery / etc. icons would just fade in and out. How can I achieve this?
The effect I'm looking for is basically what the Spotify app does on the Now Playing screen when the song has a 'Canvas' (the looping video that plays along with a song) -- tapping the background causing the Now playing UI to fade out, along with the status bar. So it must be possible!
Additionally, if the phone has a notch of some sort, I don't want the status bar to become completely black, as happens with some approaches to this I've seen.
Here's the doc for the status bar and the doc for the navigation bar
I think what you are looking for is something like this :
View decorView = getWindow().getDecorView();
// Hide the status bar and navigation bar
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
You can transparent the status bar
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
For hiding StatusBar
if (Build.VERSION.SDK_INT < 16) {
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
} else if (Build.VERSION.SDK_INT < 30) {
window.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
actionBar?.hide()
} else {
window.decorView.windowInsetsController?.hide(WindowInsets.Type.statusBars())
}
So I want to be able to show fullscreen dialog with status bar on top of it (dialog itself being behind the status bar). But I can't seem to find a way to do this.
I cannot use
dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
Because it makes status bar dissapear completely.
If I try to use:
<item name="android:windowTranslucentStatus">true</item>
I am able to go below status bar, but status bar is still grey (I believe it uses some level of transparency to darken the content behind)
This option doesn't work when combined with android:windowTranslucentStatus:
<item name="android:statusBarColor">#color/transparent</item>
Content doesn't go behind status bar if I use:
android:fitsSystemWindows="true"
My content goes behind navigation bar if I use this:
setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
So how do I achieve what I want?
I use White Action Bar and i want to use black color icons to Open Navigation drawer and more options button?
I tried using a White Action Bar but i end up getting all the icons or the buttons to be invisible in the Action bar since they are also in white color.
Kindly suggest how can i set color to the Action bar elements, as of now i want to display black icons on the Action bar with shadow.
Voila! I have found the answer.
Just Replace the code in styles.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light" />
Note: When u use a Light theme, it is understood that you will use only light colours in the action bar and therefore the colour of the text and icons are made dark(black).
Thank me later!
I'm currently working on something where I want the status and navigation bars to be transparent, with the content going behind them. Currently, I have the bars set to #android:color/transparent in styles.xml and am able to get the content behind the status bar with this code:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
However I am still struggling to get it behind the nav bar. Any help appreciated.
Thanks,
Josh
You need:
getWindow()
.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Check out the answer here:
Showing content behind status and navigation bar
Try to add these in your activity's style.xml:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>
hope this can help.
I'm trying to make Navigation Bar transparent, but keep Action Bar as it is.
Following code makes both transparent:
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
Please suggest how to make transparent Navigation Bar only.
Edit :
After reading the source, i understood the problem. The OP has not declared the styles in a proper way ie., the custom themes were not extending the default themes. Hence it made the actionbar to be transparent.
Previous Answer :
If you are targeting kitkat and above, add the following to your style. (Else do it in values-v19 styles file)
<item name="android:windowTranslucentNavigation">true</item>
this will make the navigation bar translucent.
Or you can do it programmatically,
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);