Home > Blockchain >  How to set the background color of system navigation bar to the one of the new Bottom Navigation bar
How to set the background color of system navigation bar to the one of the new Bottom Navigation bar

Time:12-29

I tried using this:

<item name="android:navigationBarColor">?attr/colorSurface</item>

but it isn't giving me the desired result.. like the one shown in the docs: enter image description here enter image description here

I recently switched to Material 3.

If you want full code of the app: https://github.com/Sujal1245/WALLisWALL-Wallpaper-App

CodePudding user response:

Try adding this line to your main theme :

<item name="colorSurface">@color/"container color"</item>

CodePudding user response:

Alternative for those who wants to use 2 versions of colorSurface(depending upon the dark mode):-

if (isNight) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        getWindow().setNavigationBarColor(getResources().getColor(R.color.navColorDark));
    } else {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        getWindow().setNavigationBarColor(getResources().getColor(R.color.navColorLight));
    }

The values for me were these in my case(Note: This will be different as per the primary color used by the app I figured these out by observation in my case which actually isn't the efficient way but it works xD)

<color name="navColorLight">#e8f5e9</color>
<color name="navColorDark">#192a24</color>
  • Related