Search code examples
androidtranslate-animation

Animating transition with a slide up


I'm trying to create an animation that I use with an overridePendingTransition() method. However I can't get the result I want. I want the first activity to slide up out of the screen and the second activity coming in from the bottom. The bottom animation works, but I can't get the first activity to slide up. Currently I use this animation:

 <set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
    android:duration="600"
    android:fillAfter="true"
    android:fromYDelta="100%p"
    android:shareInterpolator="false"
    android:toYDelta="0%p" />
 </set>

But this just makes it slide down to the bottom of the screen, I've tried a lot of value combinations but can't get it to work.


Solution

  • use this

    <?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="500"
        android:fromYDelta="0%"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toYDelta="-100%" />
    

    here interpolator : An interpolator defines the rate of change of an animation. This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated, etc.

    source