歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android開發經驗一判斷當前屏幕是全屏還是非全屏

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

日期:2017/3/1 10:27:40   编辑:Linux編程

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

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