开发者

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

开发者 https://www.devze.com 2023-01-09 03:15 出处:网络
Android includes config_longAnimTime config_medi开发者_如何学CumAnimTime config_shortAnimTime but the actual values identified by these constants don\'t make sense as milliseconds.I\'m sure they ge

Android includes

config_longAnimTime
config_medi开发者_如何学CumAnimTime
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.


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.


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


Here we go:

config_longAnimTime   = 400
config_mediumAnimTime = 300
config_shortAnimTime  = 150


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消