kotlin
val windowManager = window.windowManager
val point = Point()
windowManager.defaultDisplay.getRealSize(point)
//屏幕实际宽度(像素个数)
val width: Int = point.x
//屏幕实际高度(像素个数)
val height: Int = point.y
java
WindowManager windowManager = getWindow().getWindowManager();
Point point = new Point();
windowManager.getDefaultDisplay().getRealSize(point);
//屏幕实际宽度(像素个数)
int width = point.x;
//屏幕实际高度(像素个数)
int height = point.y;