Codename One 的 getDeviceDensity() 方法的结果应该如何使用?
How should the result of getDeviceDensity() method from Codename One be used?
根据我在模拟器中使用的皮肤不同,以下方法的结果会有所不同:
Display.getInstance().getDeviceDensity();
结果与实际设备密度无关,因为对于 Xoom 皮肤它输出 30(实际上是 149 ppi),对于 Iphone 6 它输出 50(实际上是 329)。
我注意到了,因为我需要将以 Gimp (72 dpi) 测量的字符高度转换到设备世界中,以便它在图像上看起来相似。
任何有关该主题的帮助将不胜感激!
干杯
getDeviceDensity 状态的 JavaDocs:
Returns one of the density variables appropriate for this device,
notice that density doesn't always correspond to resolution and an
implementation might decide to change the density based on DPI
constraints.
Returns:
one of the DENSITY constants of Display
DENSITY 常数指的是 one of these。
请注意,您也可以使用 convertToPixels,这可能比 API 好得多。密度 API 主要用于选择正确的多图像,用户代码中应该很少使用。
根据我在模拟器中使用的皮肤不同,以下方法的结果会有所不同:
Display.getInstance().getDeviceDensity();
结果与实际设备密度无关,因为对于 Xoom 皮肤它输出 30(实际上是 149 ppi),对于 Iphone 6 它输出 50(实际上是 329)。
我注意到了,因为我需要将以 Gimp (72 dpi) 测量的字符高度转换到设备世界中,以便它在图像上看起来相似。
任何有关该主题的帮助将不胜感激!
干杯
getDeviceDensity 状态的 JavaDocs:
Returns one of the density variables appropriate for this device, notice that density doesn't always correspond to resolution and an implementation might decide to change the density based on DPI constraints.
Returns: one of the DENSITY constants of Display
DENSITY 常数指的是 one of these。
请注意,您也可以使用 convertToPixels,这可能比 API 好得多。密度 API 主要用于选择正确的多图像,用户代码中应该很少使用。