答案 0 :(得分:0)
是的,您可以更改它的颜色,但我不确定将其更改为透明是否会产生您想要的效果
public static void setStatusBarColor(Activity activity, int color){
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(activity, color));
}
答案 1 :(得分:0)
你可以这样做 - :
private void changeStatusBarColor() {
Window window = this.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
}
// finally change the color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
}