我得到了一个新应用的设计。所有尺寸均适用于 Android,并以 DP -(密度无关像素)给出。我如何将这些值转换为 Flutter 的 LP(逻辑像素)。
我知道 Window.devicePixelRatio
为我提供了每个逻辑像素的设备像素数。
DP 和 LP 之间的确切区别是什么? dp 到 lp 转换是否有任何内置方法?
最佳答案
根据文档(window.devicePixelRatio
和 Flutter for Android Developers),DP 和 LP 之间没有区别。
Device pixels are also referred to as physical pixels. Logical pixels are also referred to as device-independent or resolution-independent pixels.
Flutter doesn’t have
dp
s but there are logical pixels, which are basically the same as device-independent pixels. The so-called devicePixelRatio expresses the ratio of physical pixels in a single logical pixel.
关于mobile - 如何将Android的DP转为Flutter的LP? DP和LP有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55032853/