如何计算 Android 设备的 PPI。最具体的是 Android 平板电脑。 请注意,我要计算设备的 PPI 而不是 DPI。
最佳答案
这很简单,就像一二三 =) 例如,让我们计算 PPI 到 Nexus 5。
float LCD_Diagonal = 4.95f;
int screenHeightPx = 1920;
int screenWidthPx = 1080;
float PPI = (float)Math.sqrt((double)(screenWidthPx*screenWidthPx + screenHeightPx*screenHeightPx))/LCD_Diagonal;
Log.e(TAG, "display_page_screen_ppi: " + String.format(Locale.getDefault(),"%d %s", Math.round(PPI), "ppi"));
结果我们有 445 ppi
根据 specs 是正确的.
关于android - 计算 Android 设备的 PPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23890050/