How can I change the color of the StatusBar from the java class? For example, to change the color of the navigation bar (the bottom back, home and menu) it would be like this:
getWindow().setNavigationBarColor(getResources().getColor(R.color.colorbar_low));
I would also be interested from color or style but I can't because in AndroidManifest change the Theme AppTheme for Theme.AppCompat.Light to use the App in white and not black colors, and now changing the colorPrimary has no effect.
style:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Thank you
An option if your app has at least API 21 is to add the property
android:statusBarColor
to your style, defining the desired color:It is important to mention that this would apply to all the Activities of your application that use the theme.
Another option is to use setStatusBarColor() , like so:
or of this defining the color inside
colors.xml
: