横屏竖屏判断
方法1:
Configuration cf= this.getResources().getConfiguration();
int ori = cf.orientation ;
if(ori == cf.ORIENTATION_LANDSCAPE){
Log.v("======", "ORIENTATION_LANDSCAPE");
}else if(ori == cf.ORIENTATION_PORTRAIT){
Log.v("======", "ORIENTATION_PORTRAIT");
}
方法2:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int mWidth = dm.widthPixels;
int mHeight = dm.heightPixels;
if (mHeight > mWidth){//layout port
// 竖屏 .......
}else{//layout land
// 横屏 .......
}
// 设置全屏
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// 获取屏幕宽高
Display dis = getWindowManager().getDefaultDisplay();
int screenWidth = dis.getWidth();// 获取屏幕宽度
int screenHeight = dis.getHeight();// 获取屏幕高度