42

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
  • 39,912
  • 17
  • 102
  • 155

4 Answers4

43

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.

Oliv
  • 10,221
  • 3
  • 55
  • 76
37

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
spatialist
  • 3,206
  • 4
  • 22
  • 17
  • Thank you for the update! I'm making this the new accepted answer. – Carl Manaster Nov 14 '14 at 15:35
  • 9
    The current values (or historical ones) may be found at https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/config.xml – Alex Cohn Apr 07 '15 at 08:20
27

Here we go:

config_longAnimTime   = 400
config_mediumAnimTime = 300
config_shortAnimTime  = 150
Carl Manaster
  • 39,912
  • 17
  • 102
  • 155
  • @JosephusVillarey it was a long time ago, but I believe I just wrote some code to print out the values. – Carl Manaster Sep 04 '12 at 00:39
  • 1
    i figured. that's what i did too. i wondered if you found it somewhere in android source. – josephus Sep 04 '12 at 06:53
  • 1
    Pro tip: Define an integer resource like `@android:integer/config_mediumAnimTime` then you get the android default speeds yet can still change it around for debugging – trapper Nov 05 '12 at 11:05
  • This is measured in ms? If so, then 400 is less than half a second, hardly perceivable... – IgorGanapolsky Dec 05 '12 at 21:03
  • 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. – EpicPandaForce Jan 28 '20 at 11:23
1

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;
}
Linh
  • 57,942
  • 23
  • 262
  • 279