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?
Asked
Active
Viewed 8,632 times
3 Answers
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
-
if i do not set the animation ,what is the duration by default in android OS? – Shuai Wang Nov 04 '16 at 04:35
-
without animation why you want to set duration between activities? – sasikumar Nov 04 '16 at 04:38
-
becasue the android OS set the system animation by default – Shuai Wang Nov 04 '16 at 04:42
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.

Raviraj Subramanian
- 364
- 1
- 6
- 11