B4A Library [B4X] BBScrollingLabel - rich text scrolling label

Erel

Administrator
Staff member
Licensed User

(this is an animated gif, it is is much smoother in real usage)

BBScrollingLabel is similar to XUI Views ScrollingLabel, however it is based on BCTextEngine and can therefore display formatted text.

It is cross platform.

Usage instructions:
- Download the b4xlib and put it in the B4X additional library folder: https://www.b4x.com/android/forum/threads/103165/#content
- Add reference to BBScrollingLabel and BCTextEngine : https://www.b4x.com/android/forum/t...-bbcode-parser-rich-text-view.106207/#content
- Add BBScrollingLabel with the designer.

Code:
B4X:
Sub Globals
    Private BBScrollingLabel1 As BBScrollingLabel
    Private TextEngine As BCTextEngine
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    TextEngine.Initialize(Activity) 'change to Form.RootPane in B4J or Page.RootPanel in B4i
    BBScrollingLabel1.TextEngine = TextEngine
    BBScrollingLabel1.Text = $"[b][u]BBScrollingLabel[/u][/b]: [color=red]Red[/color] [color=0xFF08B31F]Green[/color] [color=blue]Blue[/color]. More information: [url]https://www.b4x.com[/url]..............."$
End Sub

Sub Activity_Resume
    'this is required in B4A only (when not using B4XPages). It resumes the animation after the activity was paused.
    BBScrollingLabel1.Text = BBScrollingLabel1.Text
End Sub
Updates

v1.02 - Fixes an issue in B4i where the label is resized before it is ready.
v1.01 - Fixes crash when text is empty.
- New MaxWidth designer property. Sets the maximum width of the full text.
 

Attachments

Last edited:

cooperlegend

Active Member
Licensed User
Thank you, great tool.

Two minor issues I noticed.

1) Setting single line doesn't seem to work.
2) If the label has no value set the lib crashes
 

cooperlegend

Active Member
Licensed User
Update on 1), there seems to be a limit on the text that you can add , if this is too long it wraps to a second line etc...

I want to use this as a News feed ticker, can this limit be increased somehow?
 

cooperlegend

Active Member
Licensed User
I have found one more issue with this library I am afraid.

On devices with OS 8.1 if I set the scrolling label text field to more than about 200 characters it does not show anything. Below 200 it shows and scrolls just fine.

With my other OS 9 devices I am loading around 5000 characters without issue

Compile is the same to both.

Any ideas?
 

cooperlegend

Active Member
Licensed User
OK, I ran this test code...

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private BBScrollingLabel1 As BBScrollingLabel
    Private TextEngine As BCTextEngine
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    TextEngine.Initialize(Activity)
    
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Screen")
    
    BBScrollingLabel1.TextEngine = TextEngine
    
    Dim sText As String
    
    For iX = 285 To 290
        Log(iX)
        sText = "Do to be agreeable conveying oh assurance. Wicket longer admire do barton vanity itself do in it. Preferred to sportsmen it engrossed listening. Park gate sell they west hard for the. Abode stuff noisy manor blush yet the far. Up colonel so between removed so do. Years use place decay sex worth drift age."
        sText = sText.SubString2(0,iX)
        BBScrollingLabel1.Text = sText
        Sleep(5000)
    Next

End Sub
You will see that when the bmp.width goes over 4096 then it errors as below... (running on 8.1)

B4X:
4068
286
4080
287
4096
288
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
4113
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 6 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 6 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 18 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 88 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Do full code cache collection, code=125KB, data=84KB
After code cache collection, code=97KB, data=59KB
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 206 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 166 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 174 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 402 lines
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
289
Bitmap too large to be uploaded into a texture (4113x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4130x34, max=4096x4096)
4130
Bitmap too large to be uploaded into a texture (4130x34, max=4096x4096)
uid=10064(reboot.medivsion) RenderThread identical 22 lines
Bitmap too large to be uploaded into a texture (4130x34, max=4096x4096)
Bitmap too large to be uploaded into a texture (4130x34, max=4096x4096)
On the same hardware (but running 9.0)

B4X:
285
4068
286
4080
287
4096
288
4113
289
4130
290
4142
 

cooperlegend

Active Member
Licensed User
I have just noticed that text size is not set correctly (It is always the same size regardless of the size setting)
 
Top