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: “ShowWhenLocked”, “TurnScreenOn”, “KeepScreenOn”
String: “px”
Object: { COMMAND }
app object: Layout
ovl.AddLayout
Adds a layout to the overlay.
ovl.Batch
Batch method calls to be able to set all object's properties at once.
Note that you need to specify each parameter (use “” or null to leave some out)
Inherited methods can be called by appending an underscore to the function name (ie. txt.Batch({ SetBackColor_: [“red”] })
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.