'globals:
Private cvs As B4XCanvas
Private fnt As B4XFont
Sub Turtle_Start
If cvs.TargetRect = Null Then
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 2dip, 2dip)
cvs.Initialize(p)
fnt = xui.CreateDefaultFont(20)
End If
Turtle.SetSpeedFactor(1).SetPenColor(xui.Color_Blue).SetPenSize(1)
Turtle.SetFontAndAlignment(fnt, "LEFT")
DrawUnderlineText("Asdasd asdasd")
Turtle.SetAngle(90).PenUp.MoveForward(25).PenDown
DrawUnderlineText("Second line")
End Sub
Sub DrawUnderlineText(s As String)
Dim r As B4XRect = cvs.MeasureText(s, fnt)
Turtle.PushState
Turtle.DrawText(s)
Turtle.PopState
Turtle.PushState
Turtle.PenUp.SetAngle(90).MoveForward(r.Height / 2 / xui.Scale + 3).PenDown
Turtle.SetAngle(0).MoveForward(r.Width / xui.Scale)
Turtle.PopState
End Sub