public void setStatusBarColor ( View statusBar , int color ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . KITKAT ) { Window w = getWindow ( ) ; w . setFlags ( WindowManager . LayoutParams . FLAG_TRANSLUCENT_STATUS , WindowManager . LayoutParams . FLAG_TRANSLUCENT_STATUS ) ; //status bar height int actionBarHeight = getActionBarHeight ( ) ; int statusBarHeight = getStatusBarHeight ( ) ; // System.out.println("actionBarHeight:" + actionBarHeight); // System.out.println("statusBarHeight:" + statusBarHeight); //action bar height statusBar . getLayoutParams ( ) . height = statusBarHeight ; statusBar . setBackgroundColor ( color ) ; } }
only work for > = 19