编辑:我知道如何使栏完全透明(那很容易)!但我不知道如何将操作栏背景扩展到出现在现在半透明的状态栏后面。
我有同样的问题,找到了这个库:https://github.com/jgilfelt/SystemBarTint
setupStatusBarView()
将一个视图添加到窗口装饰。这样,您可以稍后为此视图设置颜色/可绘制。
如果使用SystemBarTint库,则可以强制状态栏显示指定的颜色,然后匹配您的操作栏的背景色:
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(Color.parseColor("#DD000000"));
在这种情况下,您需要将操作栏的背景设置为:#DD000000
根据Android 4.4 APIs的描述:
你现在可以使用新主题Theme.Holo.NoActionBar.TranslucentDecor和Theme.Holo.Light.NoActionBar.TranslucentDecor使系统栏部分透明。启用透明系统栏后,您的布局将填充系统栏后面的区域,因此您还必须为布局中不应被系统栏覆盖的部分启用fitsSystemWindows。
如果您正在创建自定义主题,请将其中一个主题设置为父主题或在您的主题中包含windowTranslucentNavigation和windowTranslucentStatus样式属性中的两个新属性之一。
在您的情况(需要ActionBar)下,第二个选项 - 将这两个新属性包括在您的主题中 - 将为您提供半透明的导航栏和状态栏。
NoActionBar
主题(通常您不希望Activity的背景在ActionBar之上)。 - ianhanniballake半透明系统栏
现在,您可以使用新的主题Theme.Holo.NoActionBar.TranslucentDecor和Theme.Holo.Light.NoActionBar.TranslucentDecor使系统栏部分半透明。通过启用半透明系统栏,您的布局将填充系统栏后面的区域,因此您还必须为不应被系统栏覆盖的布局部分启用fitsSystemWindows。
如果您正在创建自定义主题,请将其中一个主题设置为父主题或在您的主题中包含windowTranslucentNavigation和windowTranslucentStatus样式属性。