转自:http://chroya.iteye.com/blog/974031

让程序全屏的方法,大家都知道,那是静态的,程序运行之初就申明了。但是如果有这样的需求:要在程序运行的过程中,执行了某个操作而使之全屏,然后还需要退出全屏,怎么做?
    如下:
Java代码  
WindowManager.LayoutParams attrs = getWindow().getAttributes();  
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;  
getWindow().setAttributes(attrs);  
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);  
    修改window的LayoutParams参数,然后加上FLAG_LAYOUT_NO_LIMITS标志,就OK了。window会自动重新布局,呈现全屏的状态。
    要退出全屏,只需要清除刚才加上的FLAG_FULLSCREEN参数,然后去掉FLAG_LAYOUT_NO_LIMITS标志。
    如下:
Java代码  
WindowManager.LayoutParams attrs = getWindow().getAttributes();  
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);  
getWindow().setAttributes(attrs);  
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);  

 

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-08-06
  • 2021-12-26
  • 2022-01-24
  • 2021-09-16
猜你喜欢
  • 2021-07-16
  • 2021-08-23
  • 2022-01-10
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案