Android Question how to set property label.setcoloranimated continuous

Nitin Joshi

Active Member
Licensed User
Hi, I want help to know, how to keep changing color of label using setcoloranimated continuously? As i observed that color animation stops after set interval.
 

Sagenut

Expert
Licensed User
Longtime User
Try if this can be useful to You.
 

Attachments

  • Label Colors.zip
    9.3 KB · Views: 146
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Process_Globals
   Private ColorsLoopIndex As Int
   Private xui As XUI
End Sub

Sub Globals
   Private Label1 As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   ChangeColorContinuously(Label1, Array As Int(xui.Color_Red, xui.Color_Green, xui.Color_Blue), 1000)
End Sub

Sub ChangeColorContinuously (v As B4XView, Clrs() As Int, Duration As Int)
   Dim MyIndex As Int = ColorsLoopIndex
   Dim i As Int
   Do While MyIndex = ColorsLoopIndex
       Dim FirstColor As Int = Clrs(i)
       i = (i + 1) Mod Clrs.Length
       Dim SecondColor As Int = Clrs(i)
       v.SetColorAnimated(Duration, FirstColor, SecondColor)
       Sleep(Duration)
   Loop
End Sub

Sub StopColorsAnimations
   ColorsLoopIndex = ColorsLoopIndex + 1
End Sub
 
Upvote 0
Top