Immersive status bar The background color of the status bar is mixed with the color of the icons inside (how to modify the color of the status bar icons)

The immersive status bar may sometimes encounter the problem of mixing the background color of the status bar and the color of the icons inside, which is difficult to distinguish. For example, if the background color of the status bar is set to white, the icons are also white. Icons are not displayed clearly.
 

sss


We can call the following method in Activity's onCreate to solve it.

public static void setDarkStatusIcon(Window window, boolean bDark) {     if (window != null) {         View decorView = window.getDecorView();         if(decorView != null){             int vis = decorView.getSystemUiVisibility();             if(bDark) {                 //Set the black status bar icon                 vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;             } else{                 //Set the white status bar icon                 vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;             }             decorView.setSystemUiVisibility(vis);         }     } }














In the picture above, the system defaults to a white status bar icon. In the picture below, after calling this method, the icon in the status bar is no longer white. It is distinguished from the color of the statusbar

jj

Guess you like

Origin blog.csdn.net/qq_36162336/article/details/82798008