我当前检索屏幕高度的android代码是这样的:
Resources.getSystem().getDisplayMetrics().heightPixels然而,当应用程序在三星S9上以全屏模式运行时(可能在类似的设备上),返回的高度与应用程序未全屏运行时的高度相同,即在全屏模式下计算时没有按钮菜单栏。
有没有更好的方法来检索高度,或者可能意识到应用程序正在全屏运行的事实?
发布于 2019-01-28 18:40:59
您可以使用
val size = Point()
windowManager.defaultDisplay.getRealSize(size)
size.y // will be your needed height或者在Java中
Point size = new Point()
getWindowManager().getDefaultDisplay().getRealSize(size)
size.y // this one will be your height希望这是你需要的。
https://stackoverflow.com/questions/54399896
复制相似问题