android - 如何在代码中动态改变 colorPrimaryDark 颜色 也就是标题栏颜色?
PHP中文网
PHP中文网 2017-04-17 17:26:01
0
2
690

5.0的标题栏颜色只能通过在style中设定吗?能不能代码动态设置?
除了StatusBarTintManager

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
大家讲道理

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);   //这里动态修改颜色
    }
黄舟

See if it helps here How to dynamically theme Android (using RxBus mode)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template