Android Question problem with animation.InitializeTranslate

khosrwb

Active Member
Licensed User
Longtime User
?
This code is wrong?
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 b As Button
   Dim p As Panel
   Dim ani As Animation
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   p.Initialize("panel11")
   b.Initialize("btn11")
   Activity.AddView(p,65%x,12%y,34%x,80%y)
   Activity.AddView(b,10%x,10%y,30%x,20%y)
   ToastMessageShow(Activity.Width,False)
   p.Color = Colors.Blue
   b.Color = Colors.Red
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btn11_Click
'   ani.InitializeTranslate("ani1",65%x,100%y,65%x,12%y)
   If p.Top = 12%y Then
     ani.InitializeTranslate("ani1",0,12%y,0,100%y)
     ani.Duration = 1000
     ani.Start(p)
   Else
     ani.InitializeTranslate("ani2",0,100%y,0,12%y)
     ani.Duration = 1000
     ani.Start(p)
     ToastMessageShow("if result is : No",False)
   End If
End Sub

Sub ani1_AnimationEnd
   p.Top = 100%y
   ToastMessageShow("End animation 1",False)
End Sub
Sub ani2_AnimationEnd
   p.Top = 12%y
   ToastMessageShow("End animation 2",False)
End Sub
 

Attachments

  • a.zip
    6.8 KB · Views: 198
Last edited:

mangojack

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

khosrwb

Active Member
Licensed User
Longtime User
should be Float values .. ??
B4X:
ani.InitializeTranslate("ani1",65,100,65,12)

I can use from this code :
B4X:
ani.InitializeTranslate("ani1",65%x,100%y,65,12%y)
but when I use from this code ( down code ), there isn't any animation ::(
B4X:
ani.InitializeTranslate("ani1",65%x,100%y,65%x,12%y)
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I have not used animation lib ... but testing seems to work as expected when Not using %xy Int values.
 
Upvote 0
Top