如何改变系统导航栏的颜色

问题描述:

的Android 5.0的指引,导航栏似乎可定制: http://www.google.com/design/spec/layout/structure.html#structure-system-bars如何改变系统导航栏的颜色

如何更改导航栏的颜色? 我想用白色的款式。

截图: enter image description hereenter image description hereenter image description hereenter image description here


编辑:在我的资源,我测试的样式:

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

但按键是白色的。我想要与第二张图像相同的渲染器。

enter image description here

+0

Downvote,你能发展吗? – alex 2014-12-10 15:52:05

+1

也许问题已经演变为一个不同的问题:我如何定制导航栏按钮的颜色? – 2015-12-09 15:07:01

导航栏不应该是彩色的

当你自定义导航栏和状态栏,要么使他们既透明或者只修改状态栏。在所有其他情况下,导航栏应保持黑色。

(来源https://developer.android.com/training/material/theme.html

但是,你可以使用这个库来实现你想要的:) https://github.com/jgilfelt/SystemBarTint

+1

感谢您的帮助,我使用属性“android:navigationBarColor”编辑了我的问题,但我不想使用库。 – alex 2014-12-07 22:44:21

活动使用此。

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
     getWindow().setNavigationBarColor(getResources().getColor(R.color.green)); 
    } 

在V21 /风格

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
    ***<item name="android:navigationBarColor">@color/colorPrimaryDark</item>*** 
</style> 

从API 27起加入本林乐,现在可以使用导航栏的光风格:

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

documentation

windowLightNavigationBar

如果设置,导航条将被绘制为使得它是具有光导航栏背景兼容。

对于此生效,该窗口必须绘制系统栏 背景与windowDrawsSystemBarBackgrounds且不得被请求的导航栏 与 windowTranslucentNavigation是半透明的。对应于装饰视图上的设置 SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR。