Example usage for android.view Window setStatusBarColor

List of usage examples for android.view Window setStatusBarColor

Introduction

In this page you can find the example usage for android.view Window setStatusBarColor.

Prototype

public abstract void setStatusBarColor(@ColorInt int color);

Source Link

Document

Sets the color of the status bar to color .

Usage

From source file:Main.java

/**
 * Sets status bar color./*w  ww.j av a2 s .  co m*/
 * @param window
 * @param color
 */
public static void setStatusBarColor(Window window, int color) {
    window.setStatusBarColor(color);
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void setTranslucentStatusBarLollipop(Window window, int color) {
    if (color != 0)
        window.setStatusBarColor(color);
    //                window.getContext()
    //                        .getResources()
    //                        .getColor(R.color. / add here your translucent color code /));
}

From source file:Main.java

public static void setStatusBarColor(Window window, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.setStatusBarColor(color);
    }//from   ww  w .  j a va 2s .  c  o m
}

From source file:Main.java

/**
 * Changes the status bar color. This only works on API 21+.
 *
 * @param window The window of the Activity
 * @param color The desired color (resource ID) for the status bar
 *///from   w w w. j  a va2  s.co  m
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void statusBarColor(Window window, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.setStatusBarColor(color);
    }
}

From source file:Main.java

/**
 * setToolBarColor//from  w  w w .  j av  a  2  s .  c om
 * @param iWindow windows affected
 * @param iColor color to set in the statusbar
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setToolBarColor(Window iWindow, int iColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        iWindow.setStatusBarColor(iColor);
    }
}

From source file:Main.java

public static void setStatusBarColor(Activity activity, int colorId) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        //      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(activity.getResources().getColor(colorId));
    }//ww w.  j  av  a2  s  . c  om
}

From source file:com.android.mail.utils.ViewUtils.java

/**
 * Sets the status bar color of the provided activity.
 *///w  w  w.java  2 s  . co  m
@SuppressLint("NewApi")
public static void setStatusBarColor(Activity activity, @ColorRes int colorId) {
    if (Utils.isRunningLOrLater() && activity != null) {
        final Window window = activity.getWindow();
        if (window != null) {
            window.setStatusBarColor(activity.getResources().getColor(colorId));
        }
    }
}

From source file:com.demo.craftscc.core.utils.ActivityUtils.java

public static void setStatusBarColor(Context mContext, int mStatusBarColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = ((Activity) mContext).getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(mContext.getResources().getColor(R.color.bg_gray));
    }//from w  ww  . java2  s  .c o m
}

From source file:Main.java

public static void setStatusBarColor(Activity activity, int colorResource) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(colorResource);
    }//from w ww .  java 2 s .  com
}

From source file:com.stockita.stockitapointofsales.utilities.Utility.java

/**
 * This method to will set the color of the statusbar to
 *//*from ww  w.  java2 s . c  om*/
public static void changeTheStatusbarColor(Activity activity, int colorResource) {
    /**
     * Change the color of the status bar
     */
    Window window = activity.getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    if (Build.VERSION.SDK_INT >= 23) {
        window.setStatusBarColor(ContextCompat.getColor(activity, colorResource));
    } else {
        window.setStatusBarColor(activity.getResources().getColor(colorResource));
    }
}