reset status bar color in android

Solutions on MaxInterview for reset status bar color in android by the best coders in the world

showing results for - "reset status bar color in android"
Jeannine
11 Jan 2020
1public static void changeStatusBarColor(Activity context, boolean change, int color){
2    if (Build.VERSION.SDK_INT >= 21)
3    {
4        Window window = context.getWindow();
5        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
6        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
7
8        if(change){
9            defaultStatusBarColor = window.getStatusBarColor();
10            window.setStatusBarColor(color);
11        }
12        else{
13            // reset
14            window.setStatusBarColor(defaultStatusBarColor);
15        }
16    }
17}
18