我有两个分辨率相同的安卓设备
Device1 -> 分辨率 480x800 屏幕对角线尺寸 -> 4.7 英寸
Device2 -> 分辨率 480x800 屏幕对角线尺寸 -> 4.0 英寸
如何查找设备对角线屏幕尺寸?
Detect 7 inch and 10 inch tablet programmatically
我使用了上面的链接,但它给出了两个设备对角线屏幕尺寸 -> 5.8
最佳答案
尝试此代码以获取以英寸为单位的屏幕尺寸
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width=dm.widthPixels;
int height=dm.heightPixels;
double wi=(double)width/(double)dm.xdpi;
double hi=(double)height/(double)dm.ydpi;
double x = Math.pow(wi,2);
double y = Math.pow(hi,2);
double screenInches = Math.sqrt(x+y);
关于android - 如何获取安卓设备的屏幕尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19155559/