My solution: Use StringBuilder to build text with html tags and assign the text to a SKLabel.
Dim sbDetail As StringBuilder
sbDetail.Initialize
sbDetail.Append($"<p>I am normal</p>"$)
sbDetail.Append($"<p style="color:red;">I am red</p>"$)
sbDetail.Append($"<p style="color:blue;">I am blue</p>"$)
sbDetail.Append($"<p style="font-size:50px;">I am big</p>"$)
SKLabel1.Text=sbDetail
[/CODE]
Be open minded. This is a cross platform library with several features: - Text drawing engine. - Text layout engine. - BBCode parser. - Two custom views that connect everything: BBCodeView - multiline, scrollable with support for embedded views. BBLabel - lightweight label. - NEW...
Be open minded. This is a cross platform library with several features: - Text drawing engine. - Text layout engine. - BBCode parser. - Two custom views that connect everything: BBCodeView - multiline, scrollable with support for embedded views. BBLabel - lightweight label. - NEW...
My solution: Use StringBuilder to build text with html tags and assign the text to a SKLabel.
Dim sbDetail As StringBuilder
sbDetail.Initialize
sbDetail.Append($"<p>I am normal</p>"$)
sbDetail.Append($"<p style="color:red;">I am red</p>"$)
sbDetail.Append($"<p style="color:blue;">I am blue</p>"$)
sbDetail.Append($"<p style="font-size:50px;">I am big</p>"$)
SKLabel1.Text=sbDetail
[/CODE]
Download the latest version here: https://www.b4x.com/android/forum/threads/banano-a-sneak-peek-into-a-progressive-web-app-library.99740/#post-627764 INTRO BANano is a new B4J library to websites/webapps with (offline) Progressive Web App support. Unlike its big brother ABMaterial, BANano...
www.b4x.com
B4X:
{B}{/B}: Bold
{I}{/I}: Italic
{U}{/U}: Underline
{SUB}{/SUB}: Subscript
{SUP}{/SUP}: Superscript
{BR}: Line break
{WBR}: Word break opportunity
{NBSP}: Non breakable space
{AL}http://...{AT}text{/AL}: Link, opening a new tab
{AS}http://...{AT}text{/AS}: Link, not opening a new tab
{C:#RRGGBB}{/C}: Color
{ST:styles}{/ST}: Add specific styles e.g. {ST:font-size:0.9rem;color:#2B485C}My text in font-size 0.9rem{/ST}
{IC:#RRGGBB}{/IC}: Icons (if the correct .css or font is loaded) e.g. {IC:#FFFFFF}fa fa-refresh{/IC}
The accepted solution works, but this is just because label.text happens to use javascripts .html() method in this case. It should not be considered the general rule. Angel_s solution is definitely the better one for formatting SKLabels, but if you really want to go beyond the basic components, you should readthe chapter on BANanoElement in the booklet (chapter 6).
BANanoElement + B4Js SmartStrings are what make BANano so powerful to make WebApps. The best advice I can give is study the booklet.
B4X:
Dim myHTML As String = $"
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
"$
Private body As BANanoElement
body.Initialize("body")
body.Append(myHTML)