Android Question animate view

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

i need to animate view on path.

I know animate view only with change frame (rectangleF) and it doesn't help me with this paths (please look attachment )

My question is how can i draw a path and how can i animate my image view from start point to end point

Thank you
 

Attachments

  • img.png
    71.9 KB · Views: 222

Erel

B4X founder
Staff member
Licensed User
Longtime User
You will need to calculate the position.

See this example (requires a layout with Button1):
B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   If FirstTime Then
     timer1.Initialize("timer1", 16)
   End If
   startTimer = DateTime.Now
   timer1.Enabled = True
End Sub

Sub Timer1_Tick
   Dim t As Float = (DateTime.Now - startTimer) / 5000 '0 to 1
   Dim r As Float = 200dip * t
   Dim ang As Float = 5 * 360 * t
   Dim x = r * SinD(ang), y = r * CosD(ang) As Float
   button1.Left = 45%x + x
   button1.Top = 45%y + y
   If t >= 1 Then timer1.Enabled = False
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…