DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools



Version1.42 is out since December 2nd 2016

Frequently Asked Questions


Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax


WebView control

(Information and examples taken from the DroidScript documentation)


You can create a control to display local or remote web pages in your App using the CreateWebView method of the app object:

web = app.CreateWebView( width, height, options, zoom );

options include “IgnoreErrors”, “NoScrollBars”, “ScrollFade”, “Overview”, “AllowZoom”, “UseBrowser”.

If you are loading remote web pages, then you might want to use the SetOnProgress method to set the name of a callback function that you want called to report the progress of loading the page.

You can use the LoadUrl method to load an internal or external web page or the LoadHtml method to load text directly from within your App.

 web.LoadUrl( url,options );
 web.LoadHtml( html,baseFolder,options );

Note: Using a WebView can be a good way of displaying colored and formatted text areas in your App. If you set the BackColor to a transparent color you can show formatted text over a background image.

If you need to, you can use the Execute method to execute JavaScript code within the WebView.

 web.Execute( text );


Some controls use the same methods.
For examples of the same methods look here.

Method Description
WebView.Capture(filename) captures jpeg of visible page
WebView.Execute( code )
WebView.GetUrl() returns the current url
WebView.LoadHtml( html,base,options )
WebView.LoadUrl( url,options )
WebView.Print() KitKat or later only
WebView.SetBackColor( color )
WebView.SetBackGradient( color1,color2,color3,p4,p5,p6,p7 )
WebView.SetBackGradientRadial( x,y,r,color1,color2,color3,p7 )
WebView.SetBackground( imagefile,options )
WebView.SetMargins( left,top,right,bottom )
WebView.SetOnProgress( callback )
WebView.SetPadding( width,height,top,bottom )
WebView.SetPosition( left,top,width,height )
WebView.SetScale( x,y )
WebView.SetSize( width,height )
WebView.SetVisibility( HideShow )

Example - Remote

function OnStart()
  lay = app.CreateLayout( "linear", "VCenter,FillXY" );
   web = app.CreateWebView( 0.8, 0.8 );
   web.SetOnProgress( web_OnProgess );
   lay.AddChild( web );
   app.AddLayout( lay );
   web.LoadUrl( "http:///www.google.com" );
function web_OnProgess( progress )
   app.Debug( "progress = " + progress );
   if( progress==100 ) app.HideProgress();

Example - Local

function OnStart()
  lay = app.CreateLayout( "linear", "VCenter,FillXY" );
   web = app.CreateWebView( 0.8, 0.8 );
   web.SetBackColor( "#00000000" );
   lay.AddChild( web );
   app.AddLayout( lay );
   web.LoadUrl( "file:///Sys/Html/Page.htm" );

Example - Direct

function OnStart()
  lay = app.CreateLayout( "linear", "VCenter,FillXY" );
   web = app.CreateWebView( 0.8, 0.8 );
   web.SetBackColor( "#00000000" );
   lay.AddChild( web );
   app.AddLayout( lay );
   var html = "<html><head>";
   html += "<meta name='viewport' content='width=device-width'>";
   html += "</head><body style='color:#fff'>Hello World!<br>";
   html += "<img src='Img/Droid2.png'>";
   html += "</body></html>";
   web.LoadHtml( html, "file:///Sys/" );
built_in/webview.txt · Last modified: 2018/08/16 00:46 by