android5.0以上版本的状态栏透明

 1  /**
 2      * android5.0以上版本的状态栏透明
 3      */
 4     void translateStatusOnAndroid5(){
 5         if (Build.VERSION.SDK_INT >= 21) {
 6             Window window = getWindow();
 7             window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
 8                     | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
 9             window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
10                     | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
11                     | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
12             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
13             window.setStatusBarColor(Color.TRANSPARENT);
14             window.setNavigationBarColor(Color.TRANSPARENT);
15         }
16     }

 

posted @ 2015-09-17 13:42  百晓生  阅读(187)  评论(0编辑  收藏  举报