问题描述
我设计的宽度,高度,填充物...以毫米为单位.我现在正试图找出如何将这些数字转换为Flutter使用的逻辑像素系统.
我发现有关设备像素比率的文档,但我我不确定如何解释该数字,我引用:
I have a design with widths, heights, paddings... in millimeters. I'm now trying to figure out how to convert those numbers to the logical pixel system Flutter uses.
I found the docs for the device pixel ratio but I'm not sure how to interpret that number and I quote:
所以我不确定这是否可行.
我的问题归结为:有没有一种简便的方法可以计算从毫米到逻辑像素,并且适用于Android和iOS?
So I am not sure if this is the way to go.
My question comes down to this: Is there an easy way to calculate from millimeter to logical pixels that works for both Android and iOS?
推荐答案
Flutter的单位是DP或DIP(又称密度无关像素).就像它的名字所暗示的那样,它与屏幕像素比率无关.
Flutter's unit is DP or dip (aka density independent pixels).Like it's name is implying, it's independent from the screen pixel ratio.
毫米有什么区别?没有什么真正重要的.转换mm> dp或dp> mm类似于mm> inch/inch> mm.
What's the difference with millimeters ? None really important.Converting mm>dp or dp>mm is similar to mm>inch/inch>mm.
它们之间的关系非常简单:
The relationship between them is fairly simple :
1英寸= 25.4毫米= 160.0 DP
1 inch = 25.4 mm = 160.0 DP
这意味着1毫米= 6.299 DP
Which means 1 mm = 6.299 DP
这篇关于从毫米计算逻辑像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!