Search code examples
androidthemesstatusbar

StatusBarColor doesn't change


I have imported this library https://github.com/neokree/MaterialNavigationDrawer for my NavigationDrawer. I used a suggested theme:

<style name="AppTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">#8bc34a</item>
    <item name="colorPrimaryDark">#558b2f</item>
    <item name="colorAccent">#FFFFFF</item>
    <item name="singleAccount">true</item>
</style>

When I create a new ActionBarActivity the statusBar is white and I can't understand why. The colorPrimaryDark is ignored. How can I make the status bar of the default color?


Solution

  • Write this code in the oncreate function of your activity

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().setStatusBarColor(Color.parseColor("#0288d1"));
    }