使用这个库: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());
}