Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device.height和device.width获取问题 #1246

Open
Jingle-Pan opened this issue Oct 26, 2024 · 9 comments
Open

device.height和device.width获取问题 #1246

Jingle-Pan opened this issue Oct 26, 2024 · 9 comments

Comments

@Jingle-Pan
Copy link

  1. Autox.js 版本:7.0.4
  2. Autox.js 下载渠道:https://github.com/kkevsekk1/AutoX/releases
  3. Android 版本:Android 9
  4. Android 机型:小米6
  5. Android 系统类别:MIUI
  6. VSCODE 扩展版本 Auto.js-Autox.js-VSCodeExt (可选,如果是连接电脑的问题需要填):
  7. 问题描述:
    device.width,device.height获取为0,旧版本6.6.5可以正常获取
@takmartian
Copy link

遇到同样问题。

@m1mark
Copy link

m1mark commented Oct 26, 2024

红米K70 同样问题

@TKWei
Copy link

TKWei commented Oct 28, 2024

oppo 也是同样问题

@steelywing
Copy link

steelywing commented Oct 29, 2024

This works for me

console.log(Packages.android.content.res.Resources.getSystem().getDisplayMetrics().widthPixels);
console.log(Packages.android.content.res.Resources.getSystem().getDisplayMetrics().heightPixels);

可以在

deviceScreenHeight=metrics1.heightPixels;
增加這個檢查

@m1mark
Copy link

m1mark commented Nov 1, 2024

This works for me

console.log(Packages.android.content.res.Resources.getSystem().getDisplayMetrics().widthPixels);
console.log(Packages.android.content.res.Resources.getSystem().getDisplayMetrics().heightPixels);

可以在

deviceScreenHeight=metrics1.heightPixels;

增加這個檢查

红米K70设备实际32001440,这段代码多次测试均为30801440。

@Jingle-Pan
Copy link
Author

用获取屏幕截图权限,截图后读图片宽高临时用着

@aiselp
Copy link
Contributor

aiselp commented Nov 1, 2024

感谢反馈,此bug将于下个版本修复 #1250

@aiyibingfeng
Copy link

7.03就一样问题

@MrMu666
Copy link

MrMu666 commented Nov 9, 2024

This works for me

console.log(Packages.android.content.res.Resources.getSystem().getDisplayMetrics().widthPixels);
console.log(Packages.android.content.res.Resources.getSystem().getDisplayMetrics().heightPixels);

可以在

deviceScreenHeight=metrics1.heightPixels;

增加這個檢查

红米K70设备实际3200_1440,这段代码多次测试均为3080_1440。

这可能是状态栏高度没有计算进去

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants