Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Label1 As Label
Private cnvs,cnvs1 As B4XCanvas
Private rect,rect1 As B4XRect
Private border As Bitmap
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
' first label from layout (width = 150, height = 40)
Label1.Text = "this is a test"
Label1.Padding = Array As Int (5dip, 5dip, 5dip, 5dip)
Label1.SetLayout(10dip,10dip,300dip,50dip)
border = LoadBitmapResize(File.DirAssets,"border_dashed.png",Label1.Width,Label1.Height,False)
cnvs.Initialize(Label1)
rect.Initialize(0,0,Label1.Width,Label1.Height)
cnvs.DrawBitmap(border,rect)
cnvs.Invalidate
' second label in code
Dim lbl As Label
lbl.Initialize("")
lbl.Text = "this is a second label"
lbl.Padding = Array As Int (5dip, 10dip, 5dip, 10dip)
lbl.SetLayout(10dip,100dip,100dip,100dip)
border = LoadBitmapResize(File.DirAssets,"border_dashed.png",lbl.Width,lbl.Height,False)
Root.AddView(lbl,10dip,100dip,100dip,100dip)
cnvs1.Initialize(lbl)
rect1.Initialize(0,0,lbl.Width,lbl.Height)
cnvs1.DrawBitmap(border,rect1)
cnvs1.Invalidate
End Sub