Android 隐藏显示StartBar

    技术2022-05-19  21

     

        private void bindStatusBar(){

                 WindowManager.LayoutParams attrs = getWindow().getAttributes();

            if((attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN){

                //go non-full screen

                fullScreen(false);

            }else{

                //go full screen

                fullScreen(true);

            }

        }

     

        private void fullScreen(boolean enable){

           

            if(enable){

                 // go full screen

                 WindowManager.LayoutParams attrs = getWindow().getAttributes();

                 attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;

                 getWindow().setAttributes(attrs);

                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

     

                 hideStatusBar=true;

             

            }else{

                 // go non-full screen

                 WindowManager.LayoutParams attrs = getWindow().getAttributes();

                 attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);

                 getWindow().setAttributes(attrs);

                 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

                 hideStatusBar=false;

                

            }

        }

     

     


    最新回复(0)