Sub DrawBorder (v As B4XView, clrs() As Int)
Dim xui As XUI
v.Color = Colors.Transparent
Dim cvs As B4XCanvas
cvs.Initialize(v)
Dim p As B4XPath
Dim r As B4XRect
r.Initialize(0, 0, v.Width, v.Height)
p.InitializeRoundedRect(r, 10dip)
cvs.ClipPath(p)
Dim bc As BitmapCreator
bc.Initialize(v.Width / xui.Scale, v.Height / xui.Scale)
bc.FillGradient(clrs, bc.TargetRect, "TOP_BOTTOM")
cvs.DrawBitmap(bc.Bitmap, cvs.TargetRect)
cvs.RemoveClip
r.Initialize(8dip, 8dip, v.Width - 8dip, v.Height - 8dip)
p.InitializeRoundedRect(r, 8dip)
cvs.ClipPath(p)
cvs.ClearRect(cvs.TargetRect) 'this will not work in B4J as ClearRect ignores the clipped path. It can be done with an extra step.
cvs.RemoveClip
cvs.Invalidate
cvs.Release
End Sub