var btn = app.CreateButton( "Left Aligned Text", 0.4, -1, "Left" );
I would do something like this.
function OnStart()
{
lay = app.CreateLayout("linear", "VCenter,FillXY");
txtBtn = app.CreateText("My Button", 0.4, -1, "Left");
txtBtn.SetBackColor("#666666");
txtBtn.SetPadding(0.01, 0.01, 0.01, 0.01);
txtBtn.SetOnTouchDown(txtBtn_OnTouchDown);
txtBtn.SetOnTouchUp(txtBtn_OnTouchUp);
txtBtn.SetTextSize(16);
lay.AddChild(txtBtn);
app.AddLayout(lay);
}
function txtBtn_OnTouchDown()
{
this.SetBackAlpha(0.5);
}
function txtBtn_OnTouchUp()
{
this.SetBackAlpha(1);
app.ShowPopup("Pressed");
}
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
lay.SetBackground( "/Sys/Img/Hello.png", "Repeat" );
txtBtn = app.CreateText( "My Button", 0.4, -1, "Left" );
txtBtn.SetPadding( 0.015, 0.015, 0.015, 0.015 );
txtBtn.SetOnTouchDown( txtBtn_OnTouchDown );
txtBtn.SetOnTouchUp( txtBtn_OnTouchUp );
txtBtn.SetTextColor( "#FFFFFF" );
txtBtn.SetTextSize( 16 );
txtBtn.ColorNormal = "323232";
txtBtn.ColorTouched = "B2B2B2";
txtBtn.SetBackColor( "#B2" + txtBtn.ColorNormal );
lay.AddChild( txtBtn );
btn = app.CreateButton( "My Button", 0.4, -1, "Left" );
btn.SetMargins( 0, 0.1, 0, 0 );
btn.SetTextSize( 16 );
lay.AddChild( btn );
app.AddLayout( lay );
}
function txtBtn_OnTouchDown()
{
this.SetBackColor( "#B2" + this.ColorTouched );
}
function txtBtn_OnTouchUp()
{
this.SetBackColor( "#B2" + this.ColorNormal );
app.ShowPopup( "Pressed" );
}A bit of infos here:
https://groups.google.com/d/topic/androidscript/EgNaexBo2C8/discussion
function txtBtn_OnTouchDown()
{
this.Canceled = false;
this.SetBackColor( "#B2" + this.ColorTouched );
}
function txtBtn_OnTouchMove( ev )
{
if( ev.X < 0 || ev.Y < 0 || ev.X > 1 || ev.Y > 1 )
{
this.Canceled = true;
this.SetBackColor( "#B2" + this.ColorNormal );
}
}
function txtBtn_OnTouchUp()
{
if( !this.Canceled )