判断当前屏幕的方向

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  int orientation = getResources().getConfiguration().orientation;
  if (orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
  } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {// 竖屏
  }
}

 

你可能感兴趣的:(判断)