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

public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main); 
         
         
         
         
        int v = this.getWindow().getAttributes().flags; 
        // 全屏 66816 – 非全屏 65792  
        if(v != 66816){//非全屏  
            this.getWindow().setFlags( 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        }else{//取消全屏  
            this.getWindow().clearFlags( 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        } 
 
    }    
 
摘自 落日小屋

發佈留言