Android 获取设备的物理尺寸

参考:http://blog.csdn.net/liangguo03/article/details/7086821

DisplayMetrics dm = new DisplayMetrics();
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);
Log.d(“debug”,”Screen inches : ” + screenInches);

得到设备的物理尺寸,注意,不是分辨率!

你可能感兴趣的:(Android)