歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

Android開發經驗一判斷當前屏幕是全屏還是非全屏

Android開發經驗一判斷當前屏幕是全屏還是非全屏:

  1. public void onCreate(Bundle savedInstanceState) {  
  2.         super.onCreate(savedInstanceState);  
  3.         setContentView(R.layout.main);  
  4.           
  5.           
  6.           
  7.           
  8.         int v = this.getWindow().getAttributes().flags;  
  9.         // 全屏 66816 - 非全屏 65792   
  10.         if(v != 66816){//非全屏   
  11.             this.getWindow().setFlags(  
  12.                     WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  13.                     WindowManager.LayoutParams.FLAG_FULLSCREEN);  
  14.         }else{//取消全屏   
  15.             this.getWindow().clearFlags(  
  16.                     WindowManager.LayoutParams.FLAG_FULLSCREEN);  
  17.         }  
  18.   
  19.     }    
Copyright © Linux教程網 All Rights Reserved