如何更改系统导航栏颜色 [英] How to change system navigation bar color

查看:104
本文介绍了如何更改系统导航栏颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 5.0 的准则中,导航栏似乎可自定义: http://www.google.com/design/spec/layout/structure.html#structure-system-bars

In guidelines of Android 5.0, the navigation bar seems customizable: http://www.google.com/design/spec/layout/structure.html#structure-system-bars

如何更改导航栏颜色? 我想使用白色样式.

How can I change the navigation bar color? I would like to use a white style.

屏幕截图:

在我的资源中,我测试了样式:

In my resources, I tested the style:

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

但是按钮是白色的.我想要与第二张图片相同的渲染器.

But the buttons are white. I would like the same renderer as the second image.

推荐答案

从API 27开始,现在可以使用导航栏的浅色样式:

Starting from API 27, it is now possible to use the light style of the navigation bar:

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

文档:

windowLightNavigationBar

如果设置,将绘制导航栏,使其与浅色导航栏背景兼容.

If set, the navigation bar will be drawn such that it is compatible with a light navigation bar background.

要使其生效,该窗口必须绘制系统栏 windowDrawsSystemBarBackgrounds和导航的背景 不得要求bar与 windowTranslucentNavigation.对应设置 装饰视图上的SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.

For this to take effect, the window must be drawing the system bar backgrounds with windowDrawsSystemBarBackgrounds and the navigation bar must not have been requested to be translucent with windowTranslucentNavigation. Corresponds to setting SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR on the decor view.

这篇关于如何更改系统导航栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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