What are the actual ms time values for Android's animTime constants?

18,163

Solution 1

Current values (since 3.x):

  • config_shortAnimTime=200
  • config_mediumAnimTime=400
  • config_longAnimTime=500

And the duration of the activity open/close and fragment open/close animations:

  • config_activityShortDur=150
  • config_activityDefaultDur=220

Solution 2

Directly read the property:

getResources().getInteger(android.R.integer.config_shortAnimTime);
getResources().getInteger(android.R.integer.config_mediumAnimTime);
getResources().getInteger(android.R.integer.config_longAnimTime);

Don't use a hard-coded value: some devices provide an option to speed up animations: a hard-coded value would ignore that setting.

Solution 3

Here we go:

config_longAnimTime   = 400
config_mediumAnimTime = 300
config_shortAnimTime  = 150

Solution 4

For anyone using java code for create and start animation.
The default duration for a animation is 300

public class ValueAnimator extends Animator implements AnimationHandler.AnimationFrameCallback {
    ...
    // How long the animation should last in ms
    private long mDuration = 300;
}
Share:
18,163
Carl Manaster
Author by

Carl Manaster

Scientific Visualization Agile Java TDD @carlmanaster SOreadytohelp

Updated on June 06, 2022

Comments

  • Carl Manaster
    Carl Manaster almost 2 years

    Android includes

    config_longAnimTime
    config_mediumAnimTime
    config_shortAnimTime
    

    but the actual values identified by these constants don't make sense as milliseconds. I'm sure they get compiled into useful values, and I can determine them with code, but I'm sure someone else knows the answer - and, more to the point, I'm sure other people will be looking for them. So please post the actual values as an answer and save everyone a little bit of time.

  • Carl Manaster
    Carl Manaster over 11 years
    @JosephusVillarey it was a long time ago, but I believe I just wrote some code to print out the values.
  • josephus
    josephus over 11 years
    i figured. that's what i did too. i wondered if you found it somewhere in android source.
  • trapper
    trapper over 11 years
    Pro tip: Define an integer resource like <integer name="slide_duration">@android:integer/config_mediumAnimTime‌​</integer> then you get the android default speeds yet can still change it around for debugging
  • IgorGanapolsky
    IgorGanapolsky over 11 years
    This is measured in ms? If so, then 400 is less than half a second, hardly perceivable...
  • Carl Manaster
    Carl Manaster over 9 years
    Thank you for the update! I'm making this the new accepted answer.
  • Alex Cohn
    Alex Cohn about 9 years
    The current values (or historical ones) may be found at android.googlesource.com/platform/frameworks/base/+/refs/hea‌​ds/…
  • EpicPandaForce
    EpicPandaForce about 4 years
    The tricky thing is that config_activityShortDur for example is now "private` through @android: so you actually have to check the source code to find the values.