获取屏幕尺寸 (screen.size)
声明
屏宽, 屏高 = screen.size()
返回值
- 屏宽 整数型
- 屏高 整数型
说明
这个函数的返回值不受当前设备的桌面或者应用的的横竖屏状态影响,也不受放大模式影响
这个函数可以在 XUI 中使用
示例
-- 根据分辨率判断设备类型
width, height = screen.size()
if width == 1080 and height == 1920 then
-- 1080P 设备(如 Redmi Note 系列)
elseif width == 1080 and height == 2340 then
-- 主流 Android 设备(如小米、OPPO、vivo)
elseif width == 1080 and height == 2400 then
-- 主流 Android 设备(如 Redmi K 系列)
elseif width == 1440 and height == 2560 then
-- 2K 分辨率设备(如 Samsung Galaxy S 系列)
elseif width == 1440 and height == 3200 then
-- 高端 Android 设备
elseif width == 720 and height == 1280 then
-- 720P 设备(入门级设备)
end