Android Question CSBuilder - Problem with Image in Multiline Text

skaliwag

Member
Licensed User
Longtime User
I am having a problem with CSBuilder when using images in multiline text.
The problem occurs when the image is the last thing on the line after text has wrapped onto the next line.

In this screenshot :-
The Red label has the image one position before the end.
The Green label has the image at the end - the image is not displayed.
The Blue label has the image one position after the end.
The Yellow label has the image at the end, but does not have anything to wrap after it.
The Magenta label has the image at the end, with wrapped text after it, but a CRLF has been manually added after the image - the image displays correctly. This is what the Green label should look like.

cs_problem.png


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Label(5) As Label
    Dim bmp As Bitmap
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim i,c As Int
    bmp.Initialize(File.DirAssets,"ultrarare.png")
    Dim cs As CSBuilder
    cs.Initialize.Append("Label1").PopAll
    For i= 0 To 4
        Label(i).Initialize("")
        Label(i).TextColor=Colors.Black
        Select i
            Case 0
                c=Colors.Red
            Case 1
                c=Colors.Green
            Case 2:
                c=Colors.Blue
            Case 3:
                c=Colors.Yellow
            Case 4:
                c=Colors.Magenta
        End Select
        Label(i).Color=c
    Next
    Activity.AddView(Label(0),0,0,100%x,20%y)
    Activity.AddView(Label(1),0,20%y,100%x,20%y)
    Activity.AddView(Label(2),0,40%y,100%x,20%y)
    Activity.AddView(Label(3),0,60%y,100%x,20%y)
    Activity.AddView(Label(4),0,80%y,100%x,20%y)
    cs.Initialize.Append("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO").Image(bmp,15dip,15dip,False).Append("OOOOOOOOOO").PopAll
    Label(0).Text=cs
    cs.Initialize.Append("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO").Image(bmp,15dip,15dip,False).Append("OOOOOOOOOO").PopAll
    Label(1).Text=cs
    cs.Initialize.Append("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO").Image(bmp,15dip,15dip,False).Append("OOOOOOOOOO").PopAll
    Label(2).Text=cs
    cs.Initialize.Append("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO").Image(bmp,15dip,15dip,False).PopAll
    Label(3).Text=cs
    cs.Initialize.Append("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO").Image(bmp,15dip,15dip,False).Append(CRLF).Append("OOOOOOOOOO").PopAll
    Label(4).Text=cs
End Sub
 
Top