我使用以下代码来获取设备屏幕尺寸。这适用于我的所有设备(Galaxy S10 除外)。 Galaxy S10 的垂直像素为 3040,此函数返回的值约为 2800?
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
最佳答案
getSize()
返回的大小不一定返回实际大小。检查文档以了解其原因,我在下面引用了 here .
The returned size may be adjusted to exclude certain system decor elements that are always visible.
It may be scaled to provide compatibility with older applications that were originally designed for smaller displays.
It can be different depending on the WindowManager to which the display belongs.
关于java - 对于 Galaxy S10,display.getSize(size) 返回错误的屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55333733/