Android Question How to include scrolling message

Nitin Joshi

Active Member
Licensed User
I would like to pop up scrolling message in my APP. I have used scrolling label for the same, however, problem is, message can be scrolled only if message can not fit into scrolling label width.

Can anyone give me logic or some clue to overcome this problem?

For the explanation purpose, I have attached screen video of the APP. In this video, i can achieve the goal when phone is in portrait mode, however, in landscape mode label is not scrolling as contain is less than label width. If message is short then even in portrait mode, it will not scroll.

Please note: I want message should scroll over entire phone width (do not want to reduce label width).
 

Attachments

  • Sample Video.zip
    139 KB · Views: 177

Nitin Joshi

Active Member
Licensed User
This had come in my mind, however, difficult to decide how many times repeat the message.

Is there rule of thumb to decide number of characters can be accommodated based on input font size, screen size and label width?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Is there rule of thumb to decide number of characters can be accommodated based on input font size, screen size and label width?
No.
The text width depends on the font, the text size and what characters.
The length of these four characters "iiii" is shorter than these four "mmmm".
To measure text width you need a Canvas.
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Is there any way to get the trigger, from scroll label, that text is scrolling?

My idea is to keep adding space till text is not started to scroll.
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
I have done it. This is actually a work around.

Now my question is....if i consider to scroll TIME (HR:MM) as text then 10 times concatenation is enough in landscape mode even for 4k resolution handset? what is the recommended concatenation?

You could just use a timer to cycle the string text, I'm pretty sure @Erel has an example of that somewhere here on the forum.
@Erel : please go through this post. If you can suggest any other way then it will be very useful (instead of work around).
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
please go through this post. If you can suggest any other way then it will be very useful (instead of work around).
Have you thought about using: BBScrollingLabel (you need BBScrollingLabel library. Here is a complete example that will scroll even with a short text. I can post an attached project, although all code is below:
B4X:
Sub Globals
    Private BBScrollingLabel1 As BBScrollingLabel
    Private TextEngine As BCTextEngine
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")  'has the customview: BBScrollingLabel1
    TextEngine.Initialize(Activity) 
    BBScrollingLabel1.TextEngine = TextEngine
    Dim s As String=  "Time 11:23 AM"
    Dim clr As String="0xFFD21111"
    BBScrollingLabel1.Text = $"[Alignment=Center][color=${clr}][b][u]${s}[/u][/b][/color][/Alignment]"$
End Sub

Sub Activity_Resume
    'this is required in B4A only. It resumes the animation after the activity was paused.
    BBScrollingLabel1.Text = BBScrollingLabel1.Text
End Sub
By the way, it is not proper to only ask Erel to help you as it makes the rest of us irrelevant. If this is not what you want just ignore it and wait for Erel to help you.
 
Upvote 0
Top