Back

SetDensity

JS Py
Hello World

Changes the dpi value (dots per inch) that affects the content of any control created afterwards.

app.SetDensity( dpi )

The smaller the value, the smaller the scaling.

See Also: GetScreenDensity

Example - Demonstration

function OnStart() {
    var dens = app.GetScreenDensity();

    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    app.SetDensity(dens / 2);
    btn = app.CreateButton( "Press Me", -1, .1 );
    lay.AddChild( btn );

    app.SetDensity(dens);
    btn = app.CreateButton( "Press Me", -1, .1 );
    lay.AddChild( btn );

    app.SetDensity(dens * 2);
    btn = app.CreateButton( "Press Me", -1, .1 );
    lay.AddChild( btn );

    app.AddLayout( lay );
}
from native import app

def OnStart():
    dens = app.GetScreenDensity()

    lay = app.CreateLayout("linear", "VCenter,FillXY")

    app.SetDensity(dens / 2)
    btn = app.CreateButton("Press Me", -1, .1)
    lay.AddChild(btn)

    app.SetDensity(dens)
    btn = app.CreateButton("Press Me", -1, .1)
    lay.AddChild(btn)

    app.SetDensity(dens * 2)
    btn = app.CreateButton("Press Me", -1, .1)
    lay.AddChild(btn)

    app.AddLayout(lay)
    Copy     Copy All       Run      
Number: integer