protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
setStatusBarColor();
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.bg);
}
SystemBarTint 链接:https://github.com/jgilfelt/SystemBarTint
setContentView(R.layout.main_activity);
setStatusBarColor();
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.bg);
}
SystemBarTint 链接:https://github.com/jgilfelt/SystemBarTint