Android Activity transition from left to right with ease in and out curve

1.9k Views Asked by At

I'm trying to add a transition animation between Activities in Android. As I'm coming from iOS I really like the transition slide from right to left when entering a new UIViewController/Activity (and left to right when leaving). I been trying to mock this animation but all I succeeded to do is to add a linear transition between Activities. This through getActivity().overridePendingTransition(R.anim.enter, R.anim.exit); where R.anim.exit and R.anim.enter is the animation files for entering and exiting a view. This is how R.anim.enter looks like:

<?xml version="1.0" encoding="utf-8"?>

<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">

<translate
    android:duration="225"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>

As I can see there is no way to add curved transitions in this file and I haven't found how to add curved transition to Activities online either.

Is there anyone who knows how to add a curved transitions between Activities similar to iOS curveEaseInOut animation in Android?

1

There are 1 best solutions below

0
On BEST ANSWER

I solved this by adding the android:interpolator="@android:anim/accelerate_decelerate_interpolator" key in the anim XML.

Final code could look something like this:

<?xml version="1.0" encoding="utf-8"?>

<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">
    <translate
        android:duration="225"
        android:fromXDelta="0%"
        android:fromYDelta="100%"
        android:toXDelta="0%"
        android:toYDelta="0%" />
</set>