gpt4 book ai didi

flutter - 逻辑像素如何转换为物理像素

转载 作者:行者123 更新时间:2023-12-04 17:33:15 25 4
gpt4 key购买 nike

第一个问题:

如果我创建一个宽度设置为 50(逻辑像素)的 Container 小部件,这个小部件最终会占用多少物理像素?
假设答案是 50*devicePixelRatio 并且四舍五入为整数值是正确的吗?

第二个问题:

这个问题在技术上来自第一个问题。假设我们有 2 台设备,每台设备的屏幕宽度相同,分辨率相同,但屏幕高度不同。理论上,两个设备的逻辑像素宽度值应该相同。
但是,一个 devicePixelRatio 会更高。因此,物理像素的最终宽度值将不同,这可能会导致容器之一溢出,因为我的假设是最终的容器小部件宽度将乘以 devicePixelRatio。

最佳答案

It is correct to assume the answer will be 50*devicePixelRatio and it will be rounded off to an integer value?



是的

This question technically arises from the first question. Let say we have 2 devices and each has the same screen width , same resolution but different screen height. In theory, the width value in logical pixels should be the same for both devices right. However, one devicePixelRatio will be higher. Hence, the eventual width value in physical pixels will be different and this might cause one of the Container to overflow since my assumption is that the eventual Container widget width will be multiplied by the devicePixelRatio.



让我们说
dvp = 1对于第一台设备和 dvp = 2第二。所以宽度为 50在第一部手机中
1 * 50 = 50设备像素

对于第二个设备,它将是
2 * 50 = 100设备像素

但是 这并不意味着 Container width将是 2x在第二部手机上,您可能会遇到溢出错误 .一点也不!!!

其实在第一部电话 50设备像素用于创建 50逻辑像素框( 清晰度降低 )和第二部手机 100设备像素用于创建 50逻辑像素框( 更多清晰度 )

关于flutter - 逻辑像素如何转换为物理像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57792255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com