Search code examples
javaandroidnavigationstatusbar

How can I keep or change the navigationBar color?


I have developed an android application, there is a picture in the foreground. When I click on the picture, I make the background change (white if it is black, if it is black it will be white) at the same time I want to change the statusBarIcon color. and for that too

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

I use. In this way, the color of the statusbar icons is gray exactly as I want, and then I want to change the color of the icons to white.

getWindow().getDecorView().setSystemUiVisibility(0);

I am executing this command. everything is normal until here.. but when I do this, the color of the navigationBar icons also changes. How can I keep it or I want to change the color of the icons on the navigation bar

enter image description here

enter image description here


Solution

  • You can do it inside styles.xml using

    <item name="android:navigationBarColor">@color/theme_color</item>
    

    If you want to do it in code use

    window.setNavigationBarColor(@ColorInt int color)