2

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

我了解到在 KitKat 上可以有一个半透明的状态栏,但这是它在 Nexus 5 上的 Android L Preview 中的外观:在此处输入图像描述

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

这是我一直在使用该库的方式:

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());
    }
4

1 回答 1

-1

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

于 2014-10-15T11:26:42.620 回答