Uses the device's screen density (sometimes called the DPI or PPI) to calculate the ideal scale value for the application. The dimensions will be calculated so that the application fills the entire stage, regardless of the screen resolution of the device (or the size of the window, where appropriate). With this in mind, it's best to use fluid layouts, to account for differences in screen resolution and aspect ratios.
On desktop and web, the contents scale factor of the stage is detected to determine the application scale.
On mobile, the appropriate scale is calculated based on the value of
Capabilities.screenDPI. The calculation is inspired by native apps on
Google's Android operating system where "density-independent pixels" are
used for layout.
The following chart shows how different screen densities map to different
scale values returned by
|xxhdpi||Retina HD (@3x)||480||3|
The density values in the table above are approximate. The screen density of an iPhone 5 is 326, so it uses the scale factor from the xhdpi/Retina bucket because 326 is closer to 320 than it is to 480.
The following example creates a
var manager = new ScreenDensityScaleManager(); application.scaleManager = manager;
var calculator = new ScreenDensityScaleCalculator(); calculator.addScaleForDensity(160, 1); calculator.addScaleForDensity(240, 1.5); calculator.addScaleForDensity(320, 2); calculator.addScaleForDensity(480, 3); var manager = new ScreenDensityScaleManager(calculator); application.scaleManager = manager;