android - Bounce animation with depth -


how can add bounce animation view go down , come should 1 time .

if set bounce interpolator y bouncing given duration want 1 time should go 5dp down , current view

    objectanimator animator = objectanimator.offloat(targetview, "translationy", 0, 50, 0);     animator.setinterpolator(new bounceinterpolator());     animator.setduration(200);     animator.start(); 

use overshootinterpolator.

doc:

an interpolator change flings forward , overshoots last value comes back.

you can adjust tension of overshoot using constructor tension parameter:

overshootinterpolator(float tension) 

tension: amount of overshoot. when tension equals 0.0f, there no overshoot , interpolator becomes simple deceleration interpolator.

default value of tension 2.0f.

example using viewpropertyanimator:

targetview.animate()     .translationy(50)     .setinterpolator(new overshootinterpolator())     .setduration(200); 

using objectanimator:

objectanimator animator = objectanimator.offloat(targetview, "translationy", 0, 50); // pass start , end values.      animator.setinterpolator(new overshootinterpolator());     animator.setduration(200);     animator.start(); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -