if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.BLUE); }
Window window = activity.getWindow(); // clear FLAG_TRANSLUCENT_STATUS flag: window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // finally change the color window.setStatusBarColor(activity.getResources().getColor(R.color.my_statusbar_color));
Window window = activity.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ContextCompat.getColor(activity, R.color.example_color));
@Override public void onDestroyActionMode(ActionMode mode) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(Color.TRANSPARENT); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void updateStatusBarColor() { if (Utils.isAndroid5()) { getWindow().setStatusBarColor(0xff888888); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void updateStatusBarColor() { if (Utils.isAndroid5()) { getWindow().setStatusBarColor(0xff111111); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(UIUtils.getThemeColorFromAttrOrRes(CompactHeaderDrawerActivity.this, R.attr.colorPrimaryDark, R.color.material_drawer_primary_dark)); } mode.getMenuInflater().inflate(R.menu.cab, menu); return true; }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mToolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white)); mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } if (Build.VERSION.SDK_INT >= 23) { Window window = getWindow(); int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; window.getDecorView().setSystemUiVisibility(systemUiVisibility); } } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); mDrawableProgress.setTint(0xffffffff); } else if (mDrawableProgress instanceof VectorDrawableCompat) { ((VectorDrawableCompat) mDrawableProgress).setTint(0xffffffff); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mAppBarLayout.setBackgroundResource(colorPrimary); mToolbarLayout.setContentScrimResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); mActionButton.setBackgroundColor(ContextCompat.getColor(this, colorPrimaryDark)); mActionButton.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, colorPrimaryDark))); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mAppBarLayout.setBackgroundResource(colorPrimary); mToolbarLayout.setContentScrimResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); mActionButton.setBackgroundColor(ContextCompat.getColor(this, colorPrimaryDark)); mActionButton.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, colorPrimaryDark))); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }