Search code examples
androidandroid-activityandroid-animationandroid-transitions

None linear activity transition animation


I want to implement a none linear activity transition animation.

My current anime xml file

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="100%p" android:toXDelta="0"
        android:duration="@android:integer/config_mediumAnimTime"/>
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
        android:duration="@android:integer/config_mediumAnimTime" />
</set>

What i want to do is animation to start slow end in faster speed.


Solution

  • android:interpolator let's you manipulate the rate of change of an animation. If you want to starts out slowly and then accelerate use AccelerateInterpolator.

    <set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromXDelta="100%p"
        android:toXDelta="0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="@android:integer/config_mediumAnimTime" />
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="@android:integer/config_mediumAnimTime" />
    </set>