首页 > 代码库 > 获取屏幕尺寸,大于7为平板,小于7为手机

获取屏幕尺寸,大于7为平板,小于7为手机

/**
* 获取屏幕物理尺寸
* @return
*/
private double getScreenSize(){
DisplayMetrics dm = new DisplayMetrics();
((Activity)getContext()).getWindowManager().getDefaultDisplay().getMetrics(dm);
double x = Math.pow(dm.widthPixels/dm.xdpi, 2);
double y = Math.pow(dm.heightPixels/dm.ydpi, 2);
double screenInches = Math.sqrt(x+y);

return screenInches;
}



获取屏幕尺寸,大于7为平板,小于7为手机