Sub AddBorder2View (V As View, FillColor As Int, StrokeColor As Int, rx As Float, ry As Float, SWidth As Float, Padding As Int)
Dim BM As Bitmap
Dim BMD As BitmapDrawable
Dim Cnv As Canvas
'We need to draw on the bitmap with a canvas
BM.InitializeMutable(V.Width,V.Height)
Cnv.Initialize2(BM)
'Sizing Variables need to be cast to floats to enable the constructor to be found.
Dim l,T,r,b As Float
l = 0
T = 0
r = V.Width
b = V.Height
'Needs a RectF object not just a Rect
Dim rect1 As JavaObject
rect1.InitializeNewInstance("android.graphics.RectF",Array As Object(l,T,r,b))
'Create a Paint.Style object
Dim PS As JavaObject
PS.InitializeStatic("android.graphics.Paint.Style")
'Create and setup a Paint object
Dim Paint,Paint1 As JavaObject
Paint.InitializeNewInstance("android.graphics.Paint",Null)
Paint.RunMethod("setStrokeWidth",Array As Object(SWidth))
Paint.RunMethod("setColor",Array As Object(StrokeColor))
Paint.RunMethod("setStyle",Array As Object(PS.GetField("STROKE")))
Paint.RunMethod("setAntiAlias",Array As Object(True))
Paint1.InitializeNewInstance("android.graphics.Paint",Null)
Paint1.RunMethod("setColor",Array As Object(FillColor))
Paint1.RunMethod("setAntiAlias",Array As Object(True))
Paint1.RunMethod("setStyle",Array As Object(PS.GetField("FILL")))
'Get the canvas object from the wrapper
Dim CnvJO As JavaObject = Cnv
CnvJO = CnvJO.GetField("canvas")
'Draw the filled round rect on the bitmap using the canvas
CnvJO.RunMethod("drawRoundRect",Array As Object(rect1,rx,ry,Paint1))
'Draw the border round rect on the bitmap using the canvas
CnvJO.RunMethod("drawRoundRect",Array As Object(rect1,rx,ry,Paint))
'Cast the Bitmap to a BitmapDrawable
BMD.Initialize(BM)
If Padding <> -1 And GetType(V) = "android.widget.TextView" Then
Dim VJO As JavaObject = V
VJO.RunMethod("setPadding",Array As Object(Padding,Padding,Padding,Padding))
End If
'Add it to the view
V.Background = BMD
End Sub