背景:我的背景是网络开发、ruby 和 javascript。我正在开发一个主要是 react-native 的应用程序,所以很可能我遗漏了一些基本的东西。
我想要什么
android 导航栏为白色,系统按钮为深色,请参阅链接中的图片 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>
发生了什么
背景和按钮都是白色的。这对用户体验来说不是很好。
** 我试过的**
这就是让我走到现在的原因 Change navigation bar icon color on Android
我试过将 style.xml 放在 values-v27
文件夹中。
最佳答案
我刚刚研究过同一个主题,发现您需要在设备/模拟器上至少运行 Android 9.0(或 API 级别 28)才能运行。
此外,我还必须将其添加到栏的颜色中:
<item name="android:navigationBarColor">@android:color/white</item>
因此,推荐步骤:
- 创建一个 values-v28 文件夹
- 插入样式:
<item name="android:navigationBarColor">@android:color/white</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">true</item>
在您的其他值文件夹中,您不得不忍受这个 windowsLightNavigationBar 不适用的事实......
小提示
我还发现了此更改的一个错误,当将应用程序置于后台然后再次打开它时,导航栏按钮会在变暗之前保持白色一秒钟
关于安卓:windowLightNavigationBar 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55173211/