morristech
5/3/2018 - 7:47 AM

Change Status Bar color during runtime on android

Change Status Bar color during runtime on android

    public static void changeStatusBarColor(final int color) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
            return;

        final Window window = getActivity().getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(color);
    }