Back

CreateOverlay

Hello World
Content:
- Methods

Overlays are displayed above everything on the screen - even on the home screen or above other applications.

ovl = app.CreateOverlay( options )

Overlays can be created from services as well which makes them almost perfect for interacting with them.

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.

Example - Memory Monitor

cfg.Portrait;

function OnStart()
{
    app.ToBack();
    lay = app.CreateLayout( "Linear" );

    img = app.CreateImage( null, .3, .1 );
    img.SetBackColor( "#66333333" );
    img.SetAutoUpdate( false );
    lay.AddChild( img );

    ovl = app.CreateOverlay();
    ovl.AddLayout( lay, 0.8, app.GetTop() );

    app.Animate( Update, 1 );
}

var lst = new Array(100).fill(1e5);

function Update( time )
{
    var mem = app.GetMemoryInfo();
    lst.push( Math.round( 100 * mem.avail / mem.total ) - 50 );
    lst = lst.slice( -100 );

    img.Clear();
    img.SetPaintColor( "red" );
    img.DrawLine( 0, mem.threshold / mem.total, 1, mem.threshold / mem.total );

    img.SetPaintColor( "white" );
    img.DrawSamples( lst, 50 );
    img.Update();
}
Copy All       Run      

Methods

The following methods are available on the Overlay object:

GetParent() → app object
number: fraction (0..1)
string: comma “,” separated
string: “px”
app object: Layout
ovl.AddLayout
Adds a layout to the overlay.
ovl.GetParent
Returns the parent control object where the object was added to - commonly a layout.
ovl.GetType
Returns the control class name.
ovl.RemoveLayout
Removes a layout from the overlay.
ovl.SetPosition
Defines the position of a contained layout.