Android Question BBCodeView design flaws

Blueforcer

Well-Known Member
Licensed User
Longtime User
I use BBCodeView to make every letter in a text clickable, if the user clicks one letter it will become red.


B4X: Copy
dim question as string = "DENZEL WASHINGTON"

Dim s As String = "[font=Unispace][Alignment=Center][TextSize=50]"
    
    For i=0 To question.Length-1
        Dim letter As String = question.CharAt(i)
        If letter=" " Then
            s = s & letter$
            Continue
        End If
        Dim m As Map = LettersList.Get(i)
        If m.Get("clicked") Then
            s = s & $"[url="${i}"][color=red]${letter}[/color][/url]"$
        Else
            s = s & $"[url="${i}"][color=green]${letter}[/color][/url]"$
        End If
    Next
    
    s=s& "[/TextSize][/Alignment][/font]"
    Sentence.Text=s

this is the output:
B4X: Copy
[font=Unispace][Alignment=Center][TextSize=50] [url="0"][color=green]D[/color][/url][url="1"][color=green]E[/color][/url][url="2"][color=green]N[/color][/url][url="3"][color=green]Z[/color][/url][url="4"][color=green]E[/color][/url][url="5"][color=green]L[/color][/url][url=""][color=white] [/color][/url][url="7"][color=green]W[/color][/url][url="8"][color=green]A[/color][/url][url="9"][color=green]S[/color][/url][url="10"][color=green]H[/color][/url][url="11"][color=green]I[/color][/url][url="12"][color=green]N[/color][/url][url="13"][color=green]G[/color][/url][url="14"][color=green]T[/color][/url][url="15"][color=green]O[/color][/url][url="16"][color=green]N[/color][/url][/TextSize][/Alignment][/font]

1668470482955.png


In contrast to a label, there are some design flaws.
- Linebreaks will not remove the spaces, so the word isnt centered anymore.
- the gaps between the letters are smaller.
- if the word doesnt fit in one line, it will not break. So it will be cut left and right.

i used CS builder before and this worked perfectly, unfortunaly it doesnt work with B4I. So i want to use BBCodeView as crossplatform solution.
is there any way to fix the problems mentioned above?
 
It doesn't look too bad.

There is a SpaceBetweenCharacters property in TextEngine that you can try to change. It is usually isn't recommended to change it, but in this case where you define each character separately it might work as you expect.

BCTextEngine only implements word wrapping.

Linebreaks will not remove the spaces, so the word isnt centered anymore
This behavior cannot be changed externally.
 
Upvote 0
It doesn't look too bad.

There is a SpaceBetweenCharacters property in TextEngine that you can try to change. It is usually isn't recommended to change it, but in this case where you define each character separately it might work as you expect.

BCTextEngine only implements word wrapping.


This behavior cannot be changed externally.
If you got a whole sentence with many words it looks very weird and is nothing wich fits in my personal quality requirements of an good app.

Is there another possibility to make letters clickable except of CSBuilder and BBcodeView? (Wich has anything I need, and can be used in B4A and B4I).
Last try could be to modify BBcodeView by myself or using a WebView.
 
Upvote 0
If you got a whole sentence with many words it looks very weird and is nothing wich fits in my personal quality requirements of an good app.
Ok.

s there another possibility to make letters clickable except of CSBuilder and BBcodeView? (Wich has anything I need, and can be used in B4A and B4I).
There is a B4i version of CSBuilder: https://www.b4x.com/android/forum/threads/csbuilder-attributedstrings-builder.79153/#content
I don't think that its "click" feature will be good enough for this case but you can try it.
 
Upvote 0
Ok.


There is a B4i version of CSBuilder: https://www.b4x.com/android/forum/threads/csbuilder-attributedstrings-builder.79153/#content
I don't think that its "click" feature will be good enough for this case but you can try it.
I tried it yesterday and it works kind of. the only problem is, that the links can not be colored seperatly as in B4A.
like your answer here:
 
Last edited:
Upvote 0
This is how my app looks like in B4A with CSBuilder. Its perfecty alligned and each letter is clickable.
but this not managable in B4I in the same way. So i tried BBCodeView on both platforms to get the same result

photo_5447254176695437029_x.jpg


photo_5447254176695437026_x.jpg
 
Upvote 0
Back
Top