Android Code Snippet [B4X] [XUI] Canvas Draw Round Rect, Arcs, Ovals


Active Member
Licensed User
XUI v1.60 introduces a new method: DrawPath

With this, now we have more options to draw:
  • Arc
  • Oval
  • RoundRect
  • LineTo

Just consult the documentation of each method of the B4XPath object, Asuming an initialized B4XCanvas (tCanvas) the relevant code is:

    Dim tRect As B4XRect
    tRect.Initialize(1dip, 1dip, MyWidth, MyHeight)
    Dim xPath As B4XPath
    xPath.InitializeRoundedRect(tRect, 10dip)
    tCanvas.DrawPath(xPath, Colors.DarkGray, False, 5)

XUI v1.60:

I just have a question to @Erel ; Why to have another object and not only add DrawRoundRect or DrawArc to the B4XCanvas?