<span style="font-family:KaiTi_GB2312;font-size:18px;">private double getScreenSizeOfDevice2() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
double width = dm.widthPixels / dm.xdpi;
double height = dm.heightPixels / dm.ydpi;
double x = Math.pow(width, 2);
double y = Math.pow(height, 2);
double screenInches = Math.sqrt(x + y);
Log.d("TAG2", "The screenInches " + screenInches);
System.out.println("2" + screenInches);
return screenInches;
}</span>
判断当前android系统的尺寸。用来区分平板和手机,亲测。
最新推荐文章于 2021-05-27 18:48:20 发布