Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default interpolator if android:interpolator is unspecified

Tags:

In Android, I know we can define animations via XML.

For example, scale_button_up.xml might look something like

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/linear_interpolator"
     android:fillBefore="true"
     android:fillAfter="true"
     android:fillEnabled="true">
    <scale
        android:duration="5000"
        android:fromXScale="0.25"
        android:fromYScale="0.25"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.75"
        android:toYScale="0.75"/>
</set>

I was wondering what the default behaviour is for Android V21+, if android:interpolator="@android:anim/linear_interpolator" were not specified.

like image 512
AlanSTACK Avatar asked Mar 15 '18 01:03

AlanSTACK


1 Answers

All *Animation classes are subclasses of Animation, and it handles setting the interpolator specified in XML attributes in its constructor. If there isn't one specified, the default AccelerateDecelerateInterpolator is set in its ensureInterpolator() method.

/**
* Gurantees that this animation has an interpolator. Will use
* a AccelerateDecelerateInterpolator is nothing else was specified.
*/
protected void ensureInterpolator() {
    if (mInterpolator == null) {
        mInterpolator = new AccelerateDecelerateInterpolator();
    }
}
like image 67
Mike M. Avatar answered Sep 21 '22 13:09

Mike M.