B4A Library [Lib] AnimationPlus

Informatix

Expert
Licensed User
Longtime User
I think you agree that, for my purpose, a simple Tag property (a simple identifier) would be enough

[I could use a module variable to store the number of events fired, but if @Informatix wants to add this property...!]
For readability of code, a variable named "LastAnimation" is more understandable than "Tag".
Anyway, AnimationPlus should be used only for very simple animations because it is very limited. Here are the alternatives (sorted by number of features/complexity):
NineOldAndroids
Accelerated Surface
LibGDX
 

LucaMs

Expert
Licensed User
Longtime User

Yes, I know these your beautiful works .

I wanted to avoid using libGDX because I need only one effect and the library weighs 2/3 MB, if I remember correctly; but I think I'll have to use it because
I was able to get almost the desired effect using AnimationPlus but I would also "need" rotation of views together with movement, scaling and fading.
 

Informatix

Expert
Licensed User
Longtime User
Then use NineOldAndroids. You don't need something as complex as libGDX (and it's not for views).
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I would also "need" rotation of views together with movement, scaling and fading
Before giving up on the AnimationPlus library, look at the AnimationSet object -- it allows you to apply multiple transitions to one animation.
 

LucaMs

Expert
Licensed User
Longtime User
Before giving up on the AnimationPlus library, look at the AnimationSet object -- it allows you to apply multiple transitions to one animation.

I'm using AnimationSet. You can add objects of type AnimationPlus to it (indeed I added 3 anims: Translate, Alpha and ScaleCenter) but if I add RotationCenter the rotation will be applied to the group (set), not to the view, "unfortunately".

Thank you, @Jeffrey Cameron
 

LucaMs

Expert
Licensed User
Longtime User


I just tried again, moving the addition of the RotationCenter animation on top and it works

Thank you again.
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
That looks very nice!

You're very welcome, and I'm happy to help. I've banged my head against this particular wall far too many times

And thanks to Informatix for his hard work making this library
 

LucaMs

Expert
Licensed User
Longtime User
Hi, @Informatix

This is strange.

I move (InitializeTranslate with PersistAfter) an ImageView and at the end of the animation I can see the view in the new right place but its coordinates are the same as before the animation.

I mean:
ImageView1.Left = 100dip
ImaveView1.Top = 100dip

...InitializeTranslate("Anim", 0, 0, 50dip, 50dip)
...PersistAfter = True

after the animation, ImageView1.Left should be 150dip (same Top) instead it is still 100dip.

Then, if I run another animation on the same view, I get "wrong results".
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Activity.NumberOfViews returns 2 !

(of course, the view cannot be in the new position AND have different coordinates).

The view I can see is a duplicate and after the animation there 2 views on my activity.

2 hours of
 

Informatix

Expert
Licensed User
Longtime User
It's not enough: I don't have control on the new View created by the animation!

AnimationPlus with PersistAfter is not useful, so.
I explained this a billion times: Animation and AnimationPlus do not move the view. PersistAfter does not reset the image position at the end of the animation; that's all. This is the behavior of the Android API. I have no control over this. You should use NineOldAndroids instead.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User

I tried:
B4X:
mAnimTranslX.InitializeFloat(ImageView1, mAnimTranslX.PROPERTY_TRANSLATION_X, ImageView1.Left, ImageView1.Left + 200dip, "animX")
mAnimTranslY.InitializeFloat(ImageView1, mAnimTranslY.PROPERTY_TRANSLATION_Y, ImageView1.Top, ImageView1.Top + 100dip, "animY")
mAnimatorSet.setDuration(1000)
mAnimatorSet.PlayTogether(Array As Object(mAnimTranslX, mAnimTranslY))

Sub Button1_Click
   mAnimatorSet.Start
End Sub

Sub animY_End
   Log(Activity.NumberOfViews)
End Sub

Same as AnimationPlus:
Activity.NumberOfViews returns 2 and ImageView1 has the same position's values (left, top) it had before the animation (it has not been moved but duplicated).


Thank you
 

Informatix

Expert
Licensed User
Longtime User
NineOldAndroids also allows to move the view yourself with noaTimeAnimator and the TimeUpdate event, which is what I use to adjust the move speed to the time span to ensure the smoothest move or to follow a curved path. No need to add the translation values of the view; it is exactly where you placed it.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…