1. 程式人生 > >Android開發之應用狀態列、導航欄都透明

Android開發之應用狀態列、導航欄都透明

 

  • 直接上程式碼
  •    
    //狀態列、導航欄都透明
    private void hideStatusBarNavigationBar() {
            if (Build.VERSION.SDK_INT = Build.VERSION_CODES.LOLLIPOP) {
                Window window = getWindow();
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION  View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.setStatusBarColor(Color.TRANSPARENT);
                window.setNavigationBarColor(Color.TRANSPARENT);
                return;
            }
            if (Build.VERSION.SDK_INT = Build.VERSION_CODES.KITKAT) {
                getWindow().addFlags( WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                getWindow().addFlags( WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    
            }
        }