是否有hava方式设置状态栏的背景颜色?我希望我的动作栏的背景颜色与状态栏保持一致。
答案 0 :(得分:0)
这只适用于Android 5.0+,您只需要使用正确的主题和参数
创建或修改themes.xml,并将主题应用于清单中的应用程序,当然,您还必须定义自己的颜色。
<强>值/的themes.xml:强>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- colorPrimary is used for the default action bar background -->
<item name=”colorPrimary”>@color/my_awesome_color</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name=”colorPrimaryDark”>@color/my_awesome_darker_color</item>
<!-- colorAccent is used as the default value for colorControlActivated,
which is used to tint widgets -->
<item name=”colorAccent”>@color/accent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight, and colorSwitchThumbNormal. -->
</style>
http://android-developers.blogspot.hk/2014/10/appcompat-v21-material-design-for-pre.html
答案 1 :(得分:-1)
colorPrimaryDark表示statusBar Color
<style name="BaseAppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/main_theme</item>
<item name="colorPrimaryDark">@color/main_theme_dark</item>
<item name="colorAccent">@color/main_theme_accent</item>
<item name="android:textColor">@color/main_theme_text_color</item>
</style>
您也可以使用
item name="android:statusBarColor"
在java中
getWindow().setStatusBarColor(Color.argb(40, 0, 0, 0));