Hi all,
I'm on create a simple app which use the power of SetLayoutAnimated method for doing animation. I know every one can do better than this but i want to share in case it is useful for community.
Basic idea is moving (any) views from one coordinate to another, in this example i only move Label view (with image drawable) who has Tag property value is not empty, so here we go...
Here is the result:
I'm on create a simple app which use the power of SetLayoutAnimated method for doing animation. I know every one can do better than this but i want to share in case it is useful for community.
Basic idea is moving (any) views from one coordinate to another, in this example i only move Label view (with image drawable) who has Tag property value is not empty, so here we go...
B4X:
Sub DoAnimation
Dim mOrigPos As Map
mOrigPos.Initialize
For Each v As View In Activity.GetAllViewsRecursive
If v Is Label And v.Tag <> "" Then
mOrigPos.Put(v.Tag, Array As Int (v.Left, v.Top, v.Width, v.Height))
Select Rnd(1,8)
Case 1
'top-left
v.Top = v.Height * -1
v.Left = v.Width * -1
Case 2
'top
v.Top = v.Height * -1
v.Left = (100%x - v.Width) / 2
Case 3
'top-right
v.Top = v.Height * -1
v.Left = 100%x
Case 4
'right
v.Top = (100%y - v.Height) / 2
v.Left = 100%x
Case 5
'bottom-right
v.Top = 100%y
v.Left = 100%x
Case 6
'bottom
v.Top = 100%y
v.Left = (100%x - v.Width) / 2
Case 7
'bottom-left
v.Top = 100%y
v.Left = v.Width * -1
Case 8
'left
v.Top = (100%y - v.Height) / 2
v.Left = v.Width * -1
End Select
End If
Next
Dim pos() As Int
For Each v As View In Activity.GetAllViewsRecursive
If v Is Label And v.Tag <> "" Then
pos = mOrigPos.Get(v.Tag)
v.SetLayoutAnimated(1000, pos(0), pos(1), pos(2), pos(3))
Sleep(0)
End If
Next
Main.onAnim = False
End Sub
Here is the result: