美文网首页
android app全屏终极方案

android app全屏终极方案

作者: 青岛大桥_Android到后端 | 来源:发表于2018-11-21 22:46 被阅读14次

    直接上代码

        /**
         * 隐藏虚拟按键,并且全屏
         */
        protected void hideBottomUIMenu() {
            //隐藏虚拟按键,并且全屏
            if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
                View v = this.getWindow().getDecorView();
                v.setSystemUiVisibility(View.GONE);
            } else if (Build.VERSION.SDK_INT >= 19) {
                //for new api versions.
                View decorView = getWindow().getDecorView();
                int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
                decorView.setSystemUiVisibility(uiOptions);
            }
        }
    
        private void showBottomUIMenu(){
            //恢复普通状态
            if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
                View v = this.getWindow().getDecorView();
                v.setSystemUiVisibility(View.VISIBLE);
            } else if (Build.VERSION.SDK_INT >= 19) {
                //for new api versions.
                View decorView = getWindow().getDecorView();
                int uiOptions = View.SCREEN_STATE_OFF;
                decorView.setSystemUiVisibility(uiOptions);
            }
        }
    

    是最好的

    相关文章

      网友评论

          本文标题:android app全屏终极方案

          本文链接:https://www.haomeiwen.com/subject/wenhqqtx.html