android 动态设置全屏

来源:互联网 发布:大数据项目视频 编辑:程序博客网 时间:2024/04/28 21:19

实现全屏函数:

private voidsetFullScreen(){
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
 }

退出全屏函数:

private voidquitFullScreen(){
      finalWindowManager.LayoutParams attrs = getWindow().getAttributes();
      attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
      getWindow().setAttributes(attrs);
      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  }