Android Question [Solved] I'm having difficulty with Animation (AnimationPlus)

RMarra

Member
Licensed User
Longtime User
I want to slide a panel to the left when a button is pressed. I created an AnimationPlus object:

B4X:
    BoatAnimation.InitializeTranslate("AnimationLeft", 0dip, 0, -130dip, 0) 
    BoatAnimation.Duration = 700
    BoatAnimation.RepeatCount = 0
    BoatAnimation.RepeatMode=BoatAnimation.INTERPOLATOR_LINEAR
    BoatAnimation.PersistAfter = True
    BoatAnimation.Start(BoatPanel1)

and I have a AnimationEnd routine:

B4X:
Sub AnimationLeft_AnimationEnd
    BoatAnimation.Stop(BoatPanel1)
End Sub

It works up until I do the BoatAnimation.Stop and the panel jumps back to where it started, even though I have BoatAnimation.PersistAfter = True

Can anyone see what I'm doing wrong?
 

rraswisak

Active Member
Licensed User
Longtime User
Try this code:
B4X:
Sub AnimationLeft_AnimationEnd
    BoatAnimation.Stop(BoatPanel1)
    BoatPanel1.Left=-BoatPanel1.Width '<-- add this line
End Sub

Usualy for this purpose i use SetLayoutAnimated as follow:

B4X:
BoatPanel1.SetLayoutAnimated(700,-BoatPanel1.Width,BoatPanel1.Top, BoatPanel1.Width, BoatPanel1.Height)
Sleep(700)
BoatPanel1.Left = -BoatPanel1.Width
 
Upvote 0
Top