You can set the status bar color programatically using the following code.
Note: The code is in C#, you can convert it into equivalent java code.
Also, the status bar text color can either be white(in a dark theme) or black(in a light theme), there are no other options to set the specific color.
private void SetStatusBarColor(Color statusBarColor, StatusBarState state)
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
var window = ((Activity)_context).Window;
window.ClearFlags(WindowManagerFlags.TranslucentStatus);
window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
window.SetStatusBarColor(statusBarColor.ToAndroid());
int newUiVisibility = (int)window.DecorView.SystemUiVisibility;
if (state == StatusBarState.Light)
{
//Dark Text to show up on your light status bar
newUiVisibility |= (int)SystemUiFlags.LightStatusBar;
}
else if (state == StatusBarState.Dark)
{
//Light Text to show up on your dark status bar
newUiVisibility &= ~(int)SystemUiFlags.LightStatusBar;
}
window.DecorView.SystemUiVisibility = (StatusBarVisibility)newUiVisibility;
}
}
public enum StatusBarState
{
Light,
Dark
}