Last active
June 20, 2018 09:47
-
-
Save rogerpujol/99b3e8229b7a958d0930 to your computer and use it in GitHub Desktop.
Example that shows how to implement a Value Animator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!