Another animation "mishap"?

boten

Active Member
Licensed User
Longtime User
Wanted to scroll some text until it reaches it's position then stop. Using translate animation and repeat count 0, I used:

B4X:
Sub Activity_Create(FirstTime As Boolean)

  ' panel, label housekeeping
   pnl.Initialize("")
   activity.AddView(pnl,0,0,100%x,100%y)
   
   lbl.Initialize("")
   pnl.AddView(lbl,pnl.width,100,pnl.Width,50)  ' start just beyond right of panel, fill entire width
   lbl.Text="Some Text"
   lbl.Gravity=Gravity.CENTER_HORIZONTAL
   lbl.Top=(pnl.Height-lbl.Height)/2-10%y
  
   ' animation  
   an.InitializeTranslate("ane",0,0,-pnl.Width,0)  ' and move all the way to left of panel
   an.Duration=3000
   an.RepeatCount=0
   an.RepeatMode=an.REPEAT_REVERSE  ' same result with: an.REPEAT_RESTART
   
   an.Start(lbl)
   
End Sub
   
Sub ane_AnimationEnd
'an.Stop(lbl)  <==== doesn't matter if active or not
Log("animend " & lbl.Left)
'lbl.Left=0    <==== this seems to be the only working solution
End Sub


but at the end of the animation the text disappears.

the log shows that lbl.Left is 480 (same as pnl.Width) so it bounced back to the initial spot.

I would think that repeat count of 0 would keep the animated view at the position it reached, am i wrong?
 

boten

Active Member
Licensed User
Longtime User
correction:

The position of the animated view isn't actually changed during the animation (varified with log at activity_pause). So specifing the "end position" at AnimationEnd is THE only solution, unless there's something I miss.
 
Upvote 0
Top