Skip to content

Instantly share code, notes, and snippets.

@rogerpujol
Last active June 20, 2018 09:47
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rogerpujol/99b3e8229b7a958d0930 to your computer and use it in GitHub Desktop.
Save rogerpujol/99b3e8229b7a958d0930 to your computer and use it in GitHub Desktop.
Example that shows how to implement a Value Animator
/**
* ValueAnimator can be type of: ofInt, ofFloat, ofObject, etc...
* Check for more info: http://developer.android.com/reference/android/animation/ValueAnimator.html
* and http://developer.android.com/guide/topics/graphics/prop-animation.html
*/
public ValueAnimator va = ValueAnimator.ofInt(0, 300);
public int mDuration = 3000; //in millis
va.setDuration(mDuration);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Integer value = (Integer) animation.getAnimatedValue();
v.getLayoutParams().height = value.intValue();
//Do whatever you need to to with the value and...
//Call invalidate if it's necessary to update the canvas
//invalidate();
}
});
va.start();
@gagandeep1984
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment