6

I want to create an animation transition in Android from one Activity to the next. But during the animation, there is a short blackout of a black background then displaying the animation of the next Activity I want to display.

I want hold the first Activity intact so the second Activity will animate and overlap the first Activity. How can I achieve this behaviour?

Here are my two current animation xml files, which aren't doing what i want to achieve:

hold.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <translate
        android:duration="2000"
        android:zAdjustment="bottom" />

</set>

enter.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <translate
        android:duration="2000"
        android:fromXDelta="90%"
        android:fromYDelta="0%"
        android:toXDelta="0%"
        android:toYDelta="0%"
        android:zAdjustment="top" />

</set>

My Java-Code:

starter.overridePendingTransition(R.anim.enter,
                R.anim.hold);

Thank you in advance, Pat

4

2 回答 2

13

进入活动动画

startActivity(new Intent(this, AnimaitonActivity.class));
overridePendingTransition(R.anim.pull_up_from_bottom, R.anim.hold);

退出活动动画

finish();
overridePendingTransition(R.anim.hold, R.anim.push_out_to_bottom);

pull_up_from_bottom.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromYDelta="100%"
    android:toYDelta="0%" />

push_out_to_bottom.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromYDelta="0%"
    android:toYDelta="100%" />

持有.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >
    <translate
        android:duration="2000"
        android:zAdjustment="bottom" />
</set>
于 2014-01-28T07:16:02.360 回答
-1

从 Activity A 过渡到 Activity B 的默认动画取决于设备。如果屏幕暂时变黑,那是因为您的设备以这种方式实现了它……但是,您可以覆盖应用程序主题用来应用自定义动画以在活动之间转换的动画。

于 2012-06-02T11:41:38.517 回答