Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change navigation bar icon color on Android

People also ask

Can you change navigation bar color on Android?

Steps to Change the Navigation Bar on Android SmartphoneOnce you give permissions to the navbar apps, you will be able to use the widgets. On the top, you will get the color widget which adds color to the navigation bar according to the app which is currently opened.

How can I change the color of my top bar in Android?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.


If you are using API 27 (Android 8.1) or greater, you can achieve it with this in your theme:

<item name="android:windowLightNavigationBar">true</item>

You can create a folder called values-v27 and place a version of your theme (in styles.xml) with a light navigation bar and the above code to get dark navigation bar buttons.
This way, users with Android 8.0 or lower will get the standard (black) navigation bar while users with Android 8.1 or greater will get a white navbar with dark buttons.


Starting from Android O it gets really straightforward, as you could just:

View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);

For this to take effect, the window must request FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS but not FLAG_TRANSLUCENT_NAVIGATION.

Documentation: https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR


You can adjust windowLightNavigationBar = true/false and navigationBarColor = @color/yourColorId

so there're 4 cases, I've made an experiment:

In short, you don't want windowLightNavigationBar= false while navigationBarColor=White

or

windowLightNavigationBar= true while navigationBarColor=Black (this will be wired on SOME devices)

enter image description here