Do you want the text to scroll automatically?
Sub Process_Globals
Dim Timer1 As Timer 'The timer that controls the animation
End Sub
Sub Globals
Dim Label1 As Label
Dim Label2 As Label
Dim ListOfScrollingLabels As List 'List of scrolling labels
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
timer1.Initialize("Timer1", 20)
End If
ListOfScrollingLabels.Initialize
Label1.Initialize("") 'Not needed if the label is added with the designer
Label2.Initialize("")
Activity.AddView(Label1, 10dip, 10dip, 150dip, 100dip)
Activity.AddView(Label2, 10dip, 130dip, 200dip, 100dip)
ListOfScrollingLabels.Add( _
ScrollingLabels.StartScrolling(Label1, "This is a very very very long sentence."))
ListOfScrollingLabels.Add( _
ScrollingLabels.StartScrolling(Label2, "jskldfjlskdj fsldk fjskldfj lskdfj lkewj flewk fjwklef ."))
Timer1.Enabled = True 'Start the scrolling
End Sub
Sub Timer1_Tick
ScrollingLabels.TimerTick(ListOfScrollingLabels)
End Sub
SL.Canvas.DrawRect(SL.DestRect, Colors.Transparent, False, 0) 'Should be True
Please leave me a few days, because the next days I won't have much time. But will look at it.Now I'm crossing my fingers that you find the solution.
I live quite close to Crans Montana, less than 50km, in the Rhône valley. If you once come over here, please let me know, we could meeet and why not drink some good wine.Went on wintersport to Crans Montana once..
Sub TimerTick (Labels As List)
Dim clrs(2) As Int
clrs(0) = Colors.RGB(128, 128, 128)
clrs(1) = Colors.RGB(255, 255, 255)
Dim gdRad As GradientDrawable
gdRad.Initialize("LEFT_RIGHT", clrs)
gdRad.CornerRadius = 5
For i = 0 To Labels.Size - 1
Dim SL As ScrollingLabel
SL = Labels.Get(i)
SL.SrcRect.Left = SL.SrcRect.Left + 1dip
SL.SrcRect.Right = SL.SrcRect.Left + SL.lbl.Width
If SL.SrcRect.Right > SL.Bitmap.Width Then
SL.SrcRect.Left = 0
SL.SrcRect.Right = SL.SrcRect.Left + SL.lbl.Width
End If
SL.lbl.Background = gdRad
SL.Canvas.Initialize(SL.lbl)
SL.Canvas.DrawBitmap(SL.Bitmap, SL.SrcRect, SL.DestRect)
SL.lbl.Invalidate
Next
End Sub
Some explanations:Initializing and I still don't understand each other very well but I will get there one day.
The attached code module allows you to scroll multiple labels.
To use it you should add the module to your project and then add code similar to:
B4X:Sub Process_Globals Dim Timer1 As Timer 'The timer that controls the animation End Sub Sub Globals Dim Label1 As Label Dim Label2 As Label Dim ListOfScrollingLabels As List 'List of scrolling labels End Sub Sub Activity_Create(FirstTime As Boolean) If FirstTime Then timer1.Initialize("Timer1", 20) End If ListOfScrollingLabels.Initialize Label1.Initialize("") 'Not needed if the label is added with the designer Label2.Initialize("") Activity.AddView(Label1, 10dip, 10dip, 150dip, 100dip) Activity.AddView(Label2, 10dip, 130dip, 200dip, 100dip) ListOfScrollingLabels.Add( _ ScrollingLabels.StartScrolling(Label1, "This is a very very very long sentence.")) ListOfScrollingLabels.Add( _ ScrollingLabels.StartScrolling(Label2, "jskldfjlskdj fsldk fjskldfj lskdfj lkewj flewk fjwklef .")) Timer1.Enabled = True 'Start the scrolling End Sub Sub Timer1_Tick ScrollingLabels.TimerTick(ListOfScrollingLabels) End Sub