Android中设置全屏的有效方法

转载请注明地址:http://blog.csdn.net/v2810769/article/details/52910393

在eclipse里可以使用以下方法

requestWindowFeature(Window.FEATURE_NO_TITLE);  
        //隐藏状态栏  
        //定义全屏参数  
        int flag= WindowManager.LayoutParams.FLAG_FULLSCREEN;  
        //获得当前窗体对象  
        Window window= MainActivity.this.getWindow();  
        //设置当前窗体为全屏显示  
        window.setFlags(flag, flag);  
        getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

requestWindowFeature(Window.FEATURE_NO_TITLE);

在android studio中会报错–>>requestFeature() must be called before adding content

在android studio里可以使用以下方法

 //隐藏状态栏
        getSupportActionBar().hide();
        //定义全屏参数
        int flag= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        //获得当前窗体对象
        Window window= MainActivity.this.getWindow();
        //设置当前窗体为全屏显示
        window.setFlags(flag, flag);
        getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

感谢观看。

猜你喜欢

转载自blog.csdn.net/zhang1223665986/article/details/80948372