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

Android:dp 转 px,pt 转 px,在有些设备上转换结果不对 #252

Closed
fullalien opened this issue Nov 1, 2022 · 0 comments
Closed
Assignees
Labels
android bug Something isn't working

Comments

@fullalien
Copy link
Collaborator

描述这个问题

dp 转换 px,在有些设备上转换值不对,我看 SDK 中实现如下
image

其中使用 Resources.getSystem().displayMetrics 获取屏幕参数,但是文档中注释如下,无法用于 dimension unit 计算
image

还有一个问题,pt 转 px, sdk 中实现如下
image

这种转换结果过与 TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, value, displayMetrics) 有差异

image
image

既然获取的字体大小可以判断 dimension unit,我认为可以在设置字体大小时传入对应 dimension unit 即可,不需要转换成 px

复现步骤

可通过分步复现该问题:

  1. 到什么页面 '...'
  2. 点击 '....'
  3. 滑动到 '....'
  4. 产生错误

预期正确的结果

请清晰和简明的描述你预期正确的结果。

截图

如果可以的话,添加截图来帮助解释您的问题。

客户端 (请填写如下信息) :

  • 设备: [e.g. iPhone6]
  • 系统: [e.g. iOS8.1]
  • GaiaX SDK版本 [e.g. 0.1.0]
  • Gaia Studio版本 [e.g. 0.1.0]
  • GaiaX 模板文件和模板数据

崩溃日志
在这里添加崩溃日志

附加信息
在这里添加有关该问题的任何其他信息。

@fullalien fullalien self-assigned this Nov 1, 2022
@fullalien fullalien added bug Something isn't working android labels Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants