Android - 获取屏幕分辨率

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;
上一篇:LINUX 命令 (积少成多中)


下一篇:js array methods