Search code examples
androidandroid-studiostatusbarandroid-appcompatmaterial-design

Using the Material Theme colorPrimary status bar won't change


So I set in my theme:

<item name="colorPrimaryDark">@color/indigo_50</item>

nothing has changed , why?

I know that:

On older platforms, AppCompat emulates the color theming where possible. At the moment this is limited to coloring the action bar and some widgets.

but: In this application works without problems:

 the AppCompat lib will color status bars on Android 4.0

and myApp:

enter image description here


Solution

  • need import:

    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'    
    

    and next add this:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    Window w = getWindow(); // in Activity's onCreate() for instance
                    w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                    w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    // enable navigation bar tint
    tintManager.setNavigationBarTintEnabled(true);
    
    
     // set a custom tint color for all system bars
     tintManager.setTintColor(Color.BLUE);