B4A Library [B4X] BBScrollingLabel - rich text scrolling label

F0DYcnZwgV.gif

(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.05 - mBase is public.
v1.04 - Fixes an issue where invalid text cannot be replaced.
v1.03 - Fixes an issue where previous text wasn't cleared.
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

  • ScrollingLabel Example.zip
    11.5 KB · Views: 1,507
  • BBScrollingLabel.b4xlib
    5.2 KB · Views: 360
Last edited:

cooperlegend

Active Member
Licensed User
Longtime 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
Longtime 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
Longtime 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
Longtime 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
Longtime User
I have just noticed that text size is not set correctly (It is always the same size regardless of the size setting)
 

Alexander Stolte

Expert
Licensed User
Longtime User
This is missing on this view.
 

amidgeha

Active Member
Licensed User
Longtime User
F0DYcnZwgV.gif

(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.
I tried the Scrollinglabel example, It does not scroll, have I done something wrong?
 

AlfaizDev

Well-Known Member
Licensed User
How do I make it from right to left
The Arabic language is supported
 
Last edited:

Lupos

Member
Good morning Sirs
Newbie question.
I'm trying to use the scrolling text on a label but i have a little problem.
The text is a sum of 2 parts.
The first is always the same, the second part change every time and all works fine.
the problem is:
The color of the first part is ok, the second part none.

LblPlaying.Text = $"[c o l o r=yellow] Now playing: [/c o l o r] "$ & (IsPlaying) & " "
(here there are spaces between the letters otherwise the text appears in yellow)

"Now playng" is yellow, "IsPlaying" (that is declared as string) is in gray.
How can i change the string "IsPlaying" in yellow?
Thank You.
 
Top