1 public void toggleFullscreen(boolean fullScreen) { 2 // fullScreen为true时全屏,否则相反 3 4 WindowManager.LayoutParams attrs = getWindow().getAttributes(); 5 6 if (fullScreen) { 7 attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; 8 } else { 9 attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; 10 } 11 12 getWindow().setAttributes(attrs); 13 }
要使用的时候直接调用方法boolean为true
注意:要达到全屏的话还要取消APP的title
怎样取消APP的title:http://www.cnblogs.com/zzw1994/p/4884757.html