如何改变导航栏的颜色? [英] how change navigation bar color?

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

问题描述

我想要状态栏半透明和导航栏其他颜色不是半透明的,如蓝色或白色

I want a status bar translucent and navigation bar other color not translucent like blue or white

我的代码

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@color/colorPrimary</item>
    </style>

活动

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Window w = getWindow();
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        } 

状态栏半透明,但导航栏没有变色。为什么?

the status bar translucent good but the navigation bar no change color . why ?

导航栏

推荐答案

更改导航颜色的方法:

values-v21 / style.xml

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

以编程方式

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.primary));
}

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

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