Android:windowLightNavigationBar无法正常工作 [英] Android: windowLightNavigationBar not working

查看:814
本文介绍了Android:windowLightNavigationBar无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我的背景是Web开发,ruby和javascript.我正在开发一个主要是本机应用程序,所以很可能我缺少一些基本的东西.

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.

我想要的

Android导航栏为白色,带有深色系统按钮,请参见链接白色导航栏

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

我的当前代码

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>

发生了什么

背景和按钮为白色.对于UX来说不是很好.

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

**我尝试过的东西**

** What I have Tried **

这就是让我现在所处的位置更改导航栏图标颜色Android

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

我尝试将style.xml放在values-v27文件夹中.

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

推荐答案

我刚刚研究了同一主题,发现您需要在设备/仿真器上至少运行Android 9.0(或API级别28)才能正常工作

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:

  • 创建一个values-v28文件夹
  • 插入样式:
<item name="android:navigationBarColor">@android:color/white</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">true</item>

在您的其他values文件夹中,您必须忍受此windowsLightNavigationBar不适用的事实...

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

小注释

我还发现了此更改的错误,将应用程序置于后台然后再次打开时,导航栏按钮在保持深色之前会保持白色一秒钟

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

这篇关于Android:windowLightNavigationBar无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆