سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

To slide up, Use

android:fromYDelta="0%p"

and

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

use this it's working fine

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top