判断activity 是横屏还是竖屏
方法 1: //根据设备配置信息
Configuration cf= this.getResources().getConfiguration(); //获取设置的配置信息
int ori = cf.orientation ; //获取屏幕方向
if(ori == cf.ORIENTATION_LANDSCAPE){
//横屏
}else if(ori == cf.ORIENTATION_PORTRAIT){
//竖屏
}
方法2: 通过设备分辨率还判断
DisplayMetrics dm = new DisplayMetrics();
mLauncher.getWindowManager().getDefaultDisplay().getMetrics(dm);
mWidth = dm.widthPixels;
mHeight = dm.heightPixels;
if (mHeight > mWidth){//layout port
// 竖屏 .......
}else{//layout land
// 横屏 .......
}