mobile - 如何将Android的DP转为Flutter的LP? DP和LP有什么区别?

标签 mobile flutter pixel units-of-measurement

我得到了一个新应用的设计。所有尺寸均适用于 Android,并以 DP -(密度无关像素)给出。我如何将这些值转换为 Flutter 的 LP(逻辑像素)。 我知道 Window.devicePixelRatio 为我提供了每个逻辑像素的设备像素数。

DP 和 LP 之间的确切区别是什么? dp 到 lp 转换是否有任何内置方法?

最佳答案

根据文档(window.devicePixelRatioFlutter 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 dps 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/

相关文章:

安卓:安全异常: "destination must be on external storage"

html - 强制 div 在移动设备上占据整个屏幕? CSS, HTML

java - flutter doctor --android-licenses 给出了一个java错误

flutter - 提供者 : "Bad state: Tried to read a provider that threw during the creation of its value"

Android 背景图像大小(以像素为单位)

c++ - 在屏幕上快速绘制像素

android - 将 “exclude module” 规则添加到 Cordova 的 plugin.xml 中的条目

ios - 在 App Store 上发布带有营销内容的移动应用程序

dart - 如果类型化函数不返回值,Dart 分析器不应该显示警告吗?

python - 如何从图像中的对象大小(以像素为单位)根据英寸厘米等测量值来测量现实世界中的对象大小?