【问题标题】:How to make Android Status Bar color match with Action Bar's using SystemBarTint lib?如何使用 SystemBarTint lib 使 Android 状态栏颜色与操作栏颜色匹配?
【发布时间】:2014-10-15 11:18:46
【问题描述】:

使用这个库:https://github.com/jgilfelt/SystemBarTint

我了解到在 KitKat 上可以有一个半透明的状态栏,但它在 Nexus 5 上的 Android L Preview 中是这样的:

是否可以让状态栏的颜色与操作栏的颜色相匹配?

这是我使用 lib 的方式:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.BrightRed));

        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        mDrawerListLayout.setPadding(0, config.getPixelInsetTop(true), config.getPixelInsetRight(), config.getPixelInsetBottom());
    }

【问题讨论】:

    标签: android statusbar translucency


    【解决方案1】:

    您不应该在 L 上使用 SystemBarTint,为状态栏着色是 Material Design 的一部分。使用 Material 主题并在您的主题中设置颜色。

    【讨论】:

    • 但是Material Design风格不支持Android L以下的任何Android版本,我想至少支持Jelly Bean
    • @Anggrian 你可以通过 backport 检查这个链接:stackoverflow.com/questions/24431977/…
    猜你喜欢
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    相关资源
    最近更新 更多