I have an application that uses theme attribute (colorPrimaryDark) to color the Status Bar on Android v21+:
private int statusBarColor;
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//hold current color of status bar
statusBarColor = getWindow().getStatusBarColor();
//set your gray color
getWindow().setStatusBarColor(0xFF555555);
}
...
}
...
@Override
public void onDestroyActionMode(ActionMode mode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//return to "old" color of status bar
getWindow().setStatusBarColor(statusBarColor);
}
...
}
});
Place it on your Application theme(both style.xml and v21 style.xml) or create custom theme for where you want to change.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_secondary</item>
<item name="colorAccent">@color/color_accent</item>
**<item name="android:statusBarColor">@color/**YOUR_COLOR**</item>**
</style>
</resources>