search

Home  >  Q&A  >  body text

android - 如何在代码中动态改变 colorPrimaryDark 颜色 也就是标题栏颜色?

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

PHP中文网PHP中文网2771 days ago691

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:28:01

    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);   //这里动态修改颜色
        }

    reply
    0
  • 黄舟

    黄舟2017-04-17 17:28:01

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

    reply
    0
  • Cancelreply