How can i pass an integer variable to an animation?

Question!

how can i pass an integer variable to an xml animation like it's mentioned here:

<alpha
    android:interpolator="@android:anim/decelerate_interpolator"
    android:fromAlpha="0.0" android:toAlpha="1.0"
    android:duration="@android:integer/config_shortAnimTime"
 />

i've no idea how to do that. At the moment the only thing i know is that i can hardcode it like this -> android:duration="200"

anyone knows the answer on that?

By : mikepenz


Answers

If you apply myAnim.setDuration(durationMillis); it will override your xml setting for this animation so it can be variable depending on the events in your program, like this:

Animation myAnim = AnimationUtils.loadAnimation(LaunchActivity.this, R.anim.my_anim);
myAnim.setDuration(500); 
image.startAnimation(myAnim);
By : Lumis


This video can help you solving your question :)
By: admin