I want a label to smoothly change from one color to another in a loop.
Right now I am using code like this:
B4X:
Sub tmrRecord_Tick
tmrRecord.Enabled = False
If tmrRecord.Interval = 300 Then
tmrRecord.Interval = 400
lblRecording.SetTextColorAnimated(400,0xFFFF0000)
Else
tmrRecord.Interval = 300
lblRecording.SetTextColorAnimated(300, Colors.ARGB(80,180,180,180))
End If
tmrRecord.Enabled = True
End Sub
But it seems like of clunky using a timer to determine when the animation finished.
Sub DoColorAnimate
lblRecording.SetTextColorAnimated(400,0xFFFF0000)
Sleep(400)
lblRecording.SetTextColorAnimated(300, Colors.ARGB(80,180,180,180))
Sleep(300)
DoSomeThing
End Sub
Sub DoSomeThing
Log ("Done")
End Sub
Sorry, I think that at first time I had not understood what you wanted to do.
Maybe something like this?
B4X:
Sub Record_Click
Recording=True
DoColorAnimate
End Sub
Sub Activity_Click
Recording=False
End Sub
Sub DoColorAnimate
Do While Recording=True
lblRecording.SetTextColorAnimated(300,0xFFFF0000)
Sleep(300)
lblRecording.SetTextColorAnimated(400, Colors.ARGB(80,180,180,180))
Sleep(400)
Loop
End Sub