B4A Library [Lib] AnimationPlus

Hello everybody,

Here's my new baby. The AnimationPlus library extends the Animation library by adding:
  • the interpolators (Bounce, Accelerate, Overshoot, Cycle, etc.)
  • two parameters:
    PersistAfter (boolean): if True, the animation does not revert to its initial state
    StartOffset (long): delay before the animation really starts
  • AnimationSet (animations on the same view are played together)
  • four new Drawables:
    AnimationDrawable: image-by-image animation
    ClipDrawable: drawable with automatic clipping (ideal for progress bars)
    LayerDrawable: multi-layer drawable
    TransitionDrawable: cross-fade between two drawables
  • for translation animations:
    PauseTranslation/ResumeTranslation/IsPaused: new functions to pause/resume the animation
    AnimationRepeat: new event
List of properties and methods

If you want a library with more possibilities, and easy to use, give a try to NineOldAndroids.

Examples : https://drive.google.com/file/d/0B-kneWWcCy7PUTNERGJIamlzSjA/view?usp=sharing&resourcekey=0-LK97oJs9aV-UHK4CWY0utw
 

Attachments

  • AnimationPlus v2.3.zip
    12.7 KB · Views: 4,616
Last edited:

MaCaveAVin

Member
Licensed User
Longtime User
Hi,

Nice library.

On my current project I'm doing rotation on a picture depending of north (compass), if user click on picture then I hold roation and picture is move and size is increased. Then I wish to allow rotation again dpending of north position.

Issue is even if I set PersistAfter, when I allow rotation again, picture come back to initial position and decrease to original size.

I'm wondering what is the best way when animationset ends to get view end position ?
I would like to set end position view as new default position. Then I could do rotation again.

May be in a near future a small library update could add a function to do that ?


Does anyone have any idea ?

Thanks
 

Informatix

Expert
Licensed User
Longtime User
Hi,

Nice library.

On my current project I'm doing rotation on a picture depending of north (compass), if user click on picture then I hold roation and picture is move and size is increased. Then I wish to allow rotation again dpending of north position.

Issue is even if I set PersistAfter, when I allow rotation again, picture come back to initial position and decrease to original size.

I'm wondering what is the best way when animationset ends to get view end position ?
I would like to set end position view as new default position. Then I could do rotation again.

May be in a near future a small library update could add a function to do that ?


Does anyone have any idea ?

Thanks
Please see posts #102 and #116
 

Informatix

Expert
Licensed User
Longtime User
Hey Informatix,

Any know how to create a simple animation with imageview BUT scaling with another PIVOT?

I mean, I need stretch a imageview to the left fixing botton down like pivot or any another pivot, like top+left, top+right, down+left, down+right.

Thanks

Alberto Iglesias
The only possibilities with Animation or AnimationPlus are a pivot set to top left or a pivot set to center. For more flexibility, see NineOldAndroids.
 

azzam223

Active Member
Licensed User
Longtime User
Hello informatix I want to move view when I touch it And move To another Position How can I do this
 

mehransafavy

New Member
Hi there
i wanna create a simple animation that rotate a button
and i got the following error on line 36
" java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference "



B4X:
  Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("check")
    Button1.Initialize("")
    A1.InitializeRotateCenter("A1",0,360,Button1)    LINE 36 ---------------> here is error
    A1.SetInterpolator(animPlus.INTERPOLATOR_LINEAR)

    A2.InitializeTranslate("A2",-90dip,-110dip,0,0)
    A2.SetInterpolator(A2.INTERPOLATOR_OVERSHOOT)

    animPlus.Initialize(False)
    animPlus.AddAnimation(A1)
    animPlus.AddAnimation(A2)
    animPlus.Duration=3000
End Sub
 

mehransafavy

New Member
Remove that, if you have Button1 in your layout "check".

Otherwise, after initializing it, you need to add it to the Activity:
Activity.AddView (Button1, 0, 0, 100dip, 50dip)

Tip: create B4XPages projects.
Thx
Do i have to do this for all view’s or Only the ones I want to had animation?
 

mehransafavy

New Member
Remove that, if you have Button1 in your layout "check".

Otherwise, after initializing it, you need to add it to the Activity:
Activity.AddView (Button1, 0, 0, 100dip, 50dip)

Tip: create B4XPages projects.
B4X:
    Activity.LoadLayout("check")
    Activity.AddView (Button1, 0, 0, 100dip, 50dip)

    A1.InitializeRotateCenter("A1",0,360,Button1)
    A1.SetInterpolator(animPlus.INTERPOLATOR_LINEAR)

    A2.InitializeTranslate("A2",-90dip,-110dip,0,0)
    A2.SetInterpolator(A2.INTERPOLATOR_OVERSHOOT)

    animPlus.Initialize(False)
    animPlus.AddAnimation(A1)
    animPlus.AddAnimation(A2)
    animPlus.Duration=3000

i still have error on line 2
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
?
 

LucaMs

Expert
Licensed User
Longtime User
i still have error on line 2
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Remove that, if you have Button1 in your layout "check".

Otherwise...
If Button1 is in your layout, you don't need to do anything else; you don't have to write Button1.Initialize or Activity.AddView.
 
Top