android.view.Window.setStatusBarColor()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中android.view.Window.setStatusBarColor()方法的一些代码示例,展示了Window.setStatusBarColor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setStatusBarColor()方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:setStatusBarColor

Window.setStatusBarColor介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

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);
}

代码示例来源:origin: stackoverflow.com

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));

代码示例来源:origin: stackoverflow.com

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));

代码示例来源:origin: mikepenz/MaterialDrawer

@Override
public void onDestroyActionMode(ActionMode mode) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().setStatusBarColor(Color.TRANSPARENT);
  }
}

代码示例来源:origin: frogermcs/InstaMaterial

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void updateStatusBarColor() {
  if (Utils.isAndroid5()) {
    getWindow().setStatusBarColor(0xff888888);
  }
}

代码示例来源:origin: frogermcs/InstaMaterial

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void updateStatusBarColor() {
  if (Utils.isAndroid5()) {
    getWindow().setStatusBarColor(0xff111111);
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: mikepenz/MaterialDrawer

@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;
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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);
    }
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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);
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

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));
  }
}

相关文章

Window类方法