Sub Class_Globals
Private Root As B4XView
#If B4J
Private fx As JFX
#End If
Private xui As XUI
Private pnlDraw As B4XView
Private layer As B4XCanvas
Private fontObject As B4XFont
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
fontObject=CreateB4XFont("calibri.ttf",50,12)
layer.Initialize(pnlDraw)
layer.DrawCircle(pnlDraw.Width/2,pnlDraw.Height/2,pnlDraw.Width/2,xui.Color_DarkGray,False,5)
layer.DrawText("Hello World!",pnlDraw.Width/2,pnlDraw.Height/2,fontObject,xui.Color_Red,"CENTER")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub CreateB4XFont(FontFileName As String, fontSize As Float, NativeFontSize As Float) As B4XFont
#If B4A
Dim TT As Typeface = Typeface.LoadFromAssets(FontFileName)
Dim fontObj As B4XFont = xui.CreateFont(TT, fontSize)
#Else If B4i
Dim TT As Font = Font.CreateNew2(FontFileName, NativeFontSize)
Dim fontObj As B4XFont = xui.CreateFont(TT, fontSize)
#Else ' B4J
Dim fontObj As B4XFont = xui.CreateFont(fx.LoadFont(File.DirAssets, FontFileName, NativeFontSize), fontSize)
#End If
Return fontObj
End Sub