Android Code Snippet Dotted lines

I need to have dotted lines in my UI. I searched the forum with "Dotted line" but could not find what I needed.

So I devised my little sub that draws dotted lines along a panel top or left with the choice of stroke width, as well as dot length and line color. A boolean parameter Vertical indicates if the line is to be along top or left.

It should be pretty easy to modify, to draw dotted borders, or to change the frequency of the dots. Right now dots and spaces have equal length, but it would not be very difficult to have spaces larger or smaller than the dot.

I am placing it here for the next user looking for that feature. Enjoy.

B4X:
Public Sub DrawDottedLine(Target As View, aColor As Int, StrokeWidth As Int, DotLength As Int, vertical As Boolean)
   Dim c As Canvas
      c.Initialize(Target)
   If vertical Then
       For i = 0 To Target.Height Step DotLength * 2
       c.DrawLine(0, i, 0, i + DotLength, aColor, StrokeWidth)
       Next
       Else
       For i = 0 To Target.Width Step DotLength * 2
       c.DrawLine(i, 0dip, i + DotLength, 0dip, aColor, StrokeWidth)
       Next
   End If
   Target.Invalidate
End Sub

To draw the lines, go for instance :
B4X:
DrawDottedLine(Panel1, 0xFF000000, 1, 10, False) 'horizontal
DrawDottedLine(Panel2, 0xFF000000, 1, 5, True) 'vertical
 
Top