void test(){
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
int orientation = display.getOrientation();
switch(orientation){
case Configuration.ORIENTATION_PORTRAIT:
//....
break;
case Configuration.ORIENTATION_LANDSCAPE:
//...
break;
default :
//...
}
}
获取屏幕宽度和高度并判断横竖屏
最新推荐文章于 2019-08-09 09:44:26 发布