4

I just wonder how long is the android system animation (the animation for Activity A switch to Activity B )duration , and how can I measure this time . Should I use some tools or use log in the code?

Shuai Wang
  • 335
  • 1
  • 8
  • 20

3 Answers3

3

The system animation time between activities or fragment is defined by (in xml):

@android:integer/config_activityShortDur
@android:integer/config_activityDefaultDur

or (in Java):

android.R.integer.config_activityShortDur
android.R.integer.config_activityDefaultDur

From the sources:

<!-- The duration (in milliseconds) of a short animation. -->
<integer name="config_shortAnimTime">200</integer>

<!-- The duration (in milliseconds) of a medium-length animation. -->
<integer name="config_mediumAnimTime">400</integer>

<!-- The duration (in milliseconds) of a long animation. -->
<integer name="config_longAnimTime">500</integer>

<!-- The duration (in milliseconds) of the activity open/close and fragment open/close animations. -->
<integer name="config_activityShortDur">150</integer>
<integer name="config_activityDefaultDur">220</integer>
aberaud
  • 909
  • 1
  • 11
  • 24
1

you can set animation duration in xml file add the line

   android:duration="yourtime" 

fade_in.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0"
       android:duration="200" />

fade_out.xml

    <?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0"
       android:fillAfter="true"
       android:duration="200" />

you can call like this

Intent i = new Intent(this, NewActivity.class);
startActivity(i);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
sasikumar
  • 12,540
  • 3
  • 28
  • 48
1

You can check all the animation duration in Android under Settings -> Developer Options. It's user preference which means you can't change it. enter image description here

Raviraj Subramanian
  • 364
  • 1
  • 6
  • 11