Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim pnl As Panel
pnl.Initialize("")
Activity.AddView(pnl,0,0, 100%x, 100%y)
Dim cvs As Canvas
cvs.Initialize(pnl)
Dim btn As Button
btn.Initialize("")
btn.Text = "Hello Friends"
btn.TextSize = 14
Dim TextWidth As Int = cvs.MeasureStringWidth("Hello Friends", btn.Typeface, 14) + getPaddingLeft(btn) + getPaddingRight(btn)
pnl.AddView(btn, 10dip, 10dip, TextWidth, 40dip)
End Sub
'Gets the Left padding of the given view
Sub getPaddingLeft(v As View) As Int
Dim jo = v As JavaObject
Return jo.RunMethod("getPaddingLeft", Null)
End Sub
'Gets the Right padding of the given view
Sub getPaddingRight(v As View) As Int
Dim jo = v As JavaObject
Return jo.RunMethod("getPaddingRight", Null)
End Sub
'Sets the padding of a view
'v = view
'Left, Top, Right, Bottom padding values in pixels
Sub setPadding(v As View, Left As Int, Top As Int, Right As Int, Bottom As Int)
Dim jo = v As JavaObject
jo.RunMethod("setPadding", Array As Object(Left, Top, Right, Bottom))
End Sub