'How to set the background color of system navigation bar to the one of the new Bottom Navigation bar in Material 3? (Android)

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



Solution 1:[1]

In addition to Nick's answer. If you are using Dynamic Coloring. Call this method after setting Dynamic Coloring. Otherwise, you will always get the same color without dynamic effects.

Code in Kotlin

DynamicColors.applyIfAvailable(this) // After this
window.navigationBarColor = SurfaceColors.SURFACE_2.getColor(this)

Thanks.

Solution 2:[2]

Try adding this line to your main theme :

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FM1024
Solution 2