判断当前屏幕的方向

@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) {// 竖屏
  }
}
原文地址:https://www.cnblogs.com/xingfuzzhd/p/3449457.html