Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
If Root.Width = 0 Then
Wait For B4XPage_Resize (Width As Int, Height As Int)
End If
Dim SVG As SVG = SVGFromString($"<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
width="467" height="462">
<rect x="80" y="60" width="250" height="250" rx="20"
style="fill:#ff0000; stroke:#000000;stroke-width:2px;" />
<rect x="140" y="120" width="250" height="250" rx="40"
style="fill:#0000ff; stroke:#000000; stroke-width:2px;
fill-opacity:0.7;" />
</svg>
"$)
ImageView1.SetBitmap(SVG.Export(ImageView1.Width, ImageView1.Height))
End Sub
Private Sub SVGFromString(s As String) As SVG
Dim svgimage As NativeObject
svgimage = svgimage.Initialize("SVGKImage").RunMethod("new", Null).RunMethod("initWithData:", Array(svgimage.ArrayToNSData(s.GetBytes("utf8"))))
Dim svg As SVG = svgimage
Return svg
End Sub