This feature is andorid4.4 support, at least api19 can be used, that is, if Android is less than 4.4, the immersion notification bar is not effective. Here's how it's done, it's very simple.
/**
* Set the notification bar This method is implemented in OnCreate (), if it is added in the parent class's OnCreate (), even if all inherited from the parent class will have an immersion notification bar.
*/
public void Initsystembar () {
if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {
Settranslucentstatus (TRUE);
Systembartintmanager Tintmanager = new Systembartintmanager (this);
Tintmanager.setstatusbartintenabled (TRUE);
Tintmanager.setstatusbartintresource (r.color.red);
}
}
/**
* Set the status of the notification bar
* @param on
*/
@SuppressLint ("Inlinedapi")
private void Settranslucentstatus (Boolean on) {
Window win = This.getwindow ();
Windowmanager.layoutparams winparams = Win.getattributes ();
Final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
if (ON) {
Winparams.flags |= bits;
} else {
Winparams.flags &= ~bits;
}
Win.setattributes (Winparams);
}
At the end add: Android:fitssystemwindows= "true" in the layout file
can be achieved.
Transparent notification bar for Android development