Hi all - I am attempting to resize a label in Activity_Create through a loop with a timer and am up a creak without a paddle but with lots of noobness.... for some reason I cannot get the timer to work. Has anyone tried something similar? The overall idea is to create the feel that the label is appearing out of nothing.
My code is below.
B4X:
Sub Process_Globals
Dim Timer1 As Timer
Dim ButtonWidth As Int
End Sub
Sub Globals
Dim Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("FiveWhyMain")
Dim UnitWidth As Int
Dim GapWidth As Int
UnitWidth = GetDeviceLayoutValues.Width / 6
GapWidth = UnitWidth / 6
'Scale up buttons
Timer1.Initialize("Timer1",1000)
Timer1.Enabled = False
Timer1.Interval = 1000
Do While ButtonWidth < UnitWidth
Timer1.Enabled = True
Timer1_Tick
Timer1.Enabled = False
Loop
If ButtonWidth < UnitWidth Then
Return
End If
End Sub
Sub Timer1_Tick
ButtonWidth = ButtonWidth + 1
Label1.Width = ButtonWidth
End Sub
Hi Erel - thanks for your suggestion. I will definitely explore the module. Being a noob (and totally enjoying it) B4A is providing quite a steep learning curve.
Hi all - I am attempting to resize a label in Activity_Create through a loop with a timer and am up a creak without a paddle but with lots of noobness.... for some reason I cannot get the timer to work. Has anyone tried something similar? The overall idea is to create the feel that the label is appearing out of nothing.
If you were to use such code, I think that it should look like this:
B4X:
...
'Scale up buttons
Timer1.Initialize("Timer1",1000)
Timer1.Enabled = True
' Timer1.Interval = 1000 -- Not needed; you set it in Initialize.
' Note: 1000 = 1 second, which is a pretty slow step time for this.
End Sub
Sub Timer1_Tick
If Label1.Width < UnitWidth Then
Label1.Width = Label1.Width + 1 ' 1 is a pretty small step. Might try 10 or more.
Else
Timer1.Enabled = False
End If
End Sub