Android Question [B4X] Problem with ScrollingLabel class

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try it with this code:
B4X:
Private Sub StartScrolling (p As B4XView, OriginalWidth As Float)
   taskIndex = taskIndex + 1
   Dim myIndex As Int = taskIndex
   Dim duration As Int = p.Width / WidthPerSecond * 1000
   Do While True
#if B4I
       Dim pp As Panel = p
       pp.SetLayoutAnimated(duration * 3, 1, -(p.Width - OriginalWidth), p.Top, p.Width, p.Height)
#else
       p.SetLayoutAnimated(duration, -(p.Width - OriginalWidth), p.Top, p.Width, p.Height)
#end if
       Sleep(duration)
       If myIndex <> taskIndex Then Return
       Sleep(800)
       p.SetLayoutAnimated(0, 0, p.Top, p.Width, p.Height)
       If myIndex <> taskIndex Then Return
   Loop
End Sub
 
Upvote 0

cooperlegend

Active Member
Licensed User
Longtime User
Thanks Erel, Unfortunately that didn't work as I was hoping.

I got a label that scrolls far too fast to read now and doesn't repeat anymore.

I am looking for a scrolling label on both platforms that starts off slowly and builds up to a speed that you can read the label at and continues to wrap around on itself so it can continue to be read.

How can I tweak the code above, I tried many settings but couldn't figure out how this routine was working
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
got a label that scrolls far too fast to read now and doesn't repeat anymore.
It should be:
B4X:
Private Sub StartScrolling (p As B4XView, OriginalWidth As Float)
   taskIndex = taskIndex + 1
   Dim myIndex As Int = taskIndex
   Dim duration As Int = p.Width / WidthPerSecond * 1000
   Do While True
#if B4I
       Dim pp As Panel = p
       duration = duration * 3
       pp.SetLayoutAnimated(duration, 1, -(p.Width - OriginalWidth), p.Top, p.Width, p.Height)
#else
       p.SetLayoutAnimated(duration, -(p.Width - OriginalWidth), p.Top, p.Width, p.Height)
#end if
       Sleep(duration)
       If myIndex <> taskIndex Then Return
       Sleep(800)
       p.SetLayoutAnimated(0, 0, p.Top, p.Width, p.Height)
       If myIndex <> taskIndex Then Return
   Loop
End Sub
 
Upvote 0
Top