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:com.qiscus.sdk.ui.QiscusChatActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    chatConfig = Qiscus.getChatConfig();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(this, chatConfig.getStatusBarColor()));
    }/*from w w w. j a va2 s  .c  o m*/
    setContentView(R.layout.activity_qiscus_chat);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    tvTitle = (TextView) findViewById(R.id.tv_title);
    tvSubtitle = (TextView) findViewById(R.id.tv_subtitle);

    onViewReady(savedInstanceState);
}

From source file:com.qasp.diego.arsp.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.parseColor("#202020"));
    }//from www  .  j a v  a 2  s  .co  m

    // TOOLBAR
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        findViewById(R.id.gradientShadow).setVisibility(View.GONE);
        ViewCompat.setElevation(toolbar, 8);
    }

    /* Setar ICONE */
    setSupportActionBar(toolbar);

    // Inflar frag
    getFragmentManager().beginTransaction().replace(R.id.fragment_container, new preferencesFrag()).commit();

}

From source file:org.dmfs.tasks.ViewTaskActivity.java

@SuppressLint("NewApi")
@Override/* w w  w  .j  a  va  2  s. co  m*/
public void updateColor(int color) {

    if (VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(darkenColor(color));
    }
}

From source file:com.geecko.QuickLyric.MainActivity.java

@TargetApi(21)
public static void setStatusBarColor(Window window, Resources.Theme theme, Integer color) {
    if (Build.VERSION.SDK_INT >= 21) {
        if (color == null) {
            TypedValue typedValue = new TypedValue();
            theme.resolveAttribute(android.R.attr.statusBarColor, typedValue, true);
            color = typedValue.data;//from   w ww.  j ava  2  s .  c o m
        }
        window.setStatusBarColor(color);
    }
}

From source file:com.adithya321.sharesanalysis.fragments.DashboardFragment.java

@Nullable
@Override//from   w  w  w  .  j  a v  a  2 s .co m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_dashboard, container, false);

    Window window = getActivity().getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    ((AppCompatActivity) getActivity()).getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));

    databaseHandler = new DatabaseHandler(getContext());
    sharesRecyclerView = (RecyclerView) root.findViewById(R.id.shares_recycler_view);
    setRecyclerViewAdapter();

    return root;
}

From source file:com.qiscus.sdk.filepicker.FilePickerActivity.java

protected void onSetStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(this, chatConfig.getStatusBarColor()));
    }//from   w w w  .  ja  v  a2s .  c  om
}

From source file:com.qiscus.sdk.ui.QiscusAccountLinkingActivity.java

protected void onSetStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(this, Qiscus.getChatConfig().getStatusBarColor()));
    }/*from  www . ja  v  a 2s  .  c om*/
}

From source file:edu.mit.lastmite.insight_library.activity.SingleFragmentActivity.java

@SuppressWarnings("UnusedDeclaration")
public void setStatusBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(color);
    }//from  w  w  w. j a v  a2 s .  c o m
}

From source file:com.miz.utils.ViewUtils.java

public static void setupWindowFlagsForStatusbarOverlay(Window window, boolean setBackgroundResource) {

    if (MizLib.isKitKat()) {
        // If we're running on KitKat, we want to enable
        // the translucent status bar
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }//  ww  w  . j a va 2s .c o m

    if (MizLib.hasKitKat()) {
        // If we're running on KitKat or above, we want to show
        // the background image beneath the status bar as well.
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }

    // Make the status bar color transparent to begin with
    if (MizLib.hasLollipop())
        window.setStatusBarColor(Color.TRANSPARENT);

    // If requested, set a background resource on the Window object
    if (setBackgroundResource)
        window.setBackgroundDrawableResource(R.drawable.bg);
}

From source file:com.grarak.kerneladiutor.BaseActivity.java

public void setStatusBarColor() {
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.setStatusBarColor(ContextCompat.getColor(this, R.color.color_primary_dark));
}