1、一般app要适配屏幕,可以写两套布局,一套大布局,一套小布局
分辨Android app加载的布局是大布局还是小布局,可以新建文件夹layout-large.
在layout-large 里放相同名字的布局文件,在屏幕超过6寸时,会自动加载此文件次夹的布局
2、代码检测机子屏幕大小
private double getScreenSizeOfDevice() {
Point point = new Point(); getWindowManager().getDefaultDisplay().getRealSize(poin t);
DisplayMetrics dm = getResources().getDisplayMetrics();
double x = Math.pow(point.x/ dm.xdpi, 2);
double y = Math.pow(point.y / dm.ydpi, 2);
double screenInches = Math.sqrt(x + y);
Log.i(TAG, "Screen inches : " + screenInches);
return screenInches;
}