Only Status bar Transparent, not a Navigation bar - android

I want to set a transparent status bar, not a navigation bar.
what I tried
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
But it set Status bar and navigation bar both transparent. I want only Status bar transparent
I also want to set different status bar color based on Fragment, And my navigation drawer is an overriding status bar, like this

Set these properties in your theme:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
And in your layout you want to have a transparent status bar, set below attribute:
android:fitsSystemWindows="true"

On Lolipop and above:
window.statusBarColor = ContextCompat.getColor(this, android.R.color.transparent)
And on Marshmallow and above for transparent status with dark icons
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
or transparent status with light icons
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

Related

How can I make the status bar / navigation bar invisible on Android, while keeping the padding at the top / bottom of the screen?

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())
}

How to change System Navigation Bar (default) icon color?

I want to change the color of the system navigation bar icon color but could only succeed to change the navigation bar background color, using these codes programmatically:
<item name="android:navigationBarColor">#color/black</item>
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.navigationBarColor = resources.getColor(R.color.primary_text_color)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //For setting material color into black of the navigation bar
}
Thanks in advance.

Is it possible to change status bar icon color to white? Or is there a dark theme status bar? (Kotlin)

In my app, I've changed the background color of the status bar to black with : window.statusBarColor = ContextCompat.getColor(this#MainActivity, R.color.black) (And it works). But now, you can't see the status bar icons! And yes, I've heard of: window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, but that sets the background (of the status bar) to white and the status bar icons to grey. Is there a way to make the status bar icons white, whilst still having a black background? Or is there a dark theme for the status bar?
In your theme, set windowLightStatusBar to false -- and you can also set your status bar color in the theme:
<item name="android:statusBarColor">#color/black</item>
<item name="android:windowLightStatusBar">false</item>
Or you can use this code snippet if you want to change it programmatically without changing your theme:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (darkIcons) {
window.decorView.systemUiVisibility = window.decorView.windowSystemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
window.decorView.systemUiVisibility = window.decorView.windowSystemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
}
}

status bar hinding the layout in android

I want my layout to start below the status bar and expand till the end of screen . Navigation bar should be hidden .
For this i have used this theme :
<style name="AppTheme.NoActionbarThemeDefaultStatusColor" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</style
for my actiivity.
And i also use below code in the oncreate method of my activity.
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
or View.SYSTEM_UI_FLAG_LOW_PROFILE)
Everything is fine i.e status bar is there , no navigation bar is there .
But the layout's top part is hidden below status bar . I want layout to start after status bar . But not sure how to do this.
Try this code...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}

Android - Fully transparent status bar with non transparent navigation bar

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>

Categories

Resources