Android: windowLightNavigationBar not working

拜拜、爱过 提交于 2020-03-26 03:01:15

问题


Background: My background is in web development, ruby and javascript. I'm working on a mostly react-native app, so very likely I'm missing something basic.

What I want

android navigation bar to be white with dark system buttons see image in link white navigation bar

My Current Code

res/values/style.xml

<resources>
  <style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowLightNavigationBar">true</item> 
    <item name="android:windowTranslucentNavigation">false</item>
    <item name="android:navigationBarColor">#FFFFFF</item>
  </style>
</resources>

What is happening instead

The background AND the buttons are white. which is not so great for UX.

** What I have Tried **

this is what got me where I am now Change navigation bar icon color on Android

I have tried putting style.xml in a values-v27 folder.


回答1:


I just worked on this same topic and found out you need to run at least Android 9.0 (or API level 28) on the device/emulator for this to work.

Also, I had to add this to the color of the bar:

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

So, recommended steps:

  • Create a values-v28 folder
  • Insert the style:
<item name="android:navigationBarColor">@android:color/white</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">true</item>

In your other values folder, you kind of have to live with the fact that this windowsLightNavigationBar doesn't apply...

Small remark

I also found a bug on this change, when putting app in background and then opening it again, the navbar buttons stay white for a second before getting the dark color




回答2:


Your code is working as intended for me. Make sure you have the file name and file path written correctly:

https://imgur.com/xclYDuZ



来源:https://stackoverflow.com/questions/55173211/android-windowlightnavigationbar-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!