Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Hold Activity During Animation

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

like image 488
Patrick Avatar asked Jun 02 '12 11:06

Patrick


1 Answers

Enter activity animation

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

Exit activity animation

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%" />

hold.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >
    <translate
        android:duration="2000"
        android:zAdjustment="bottom" />
</set>
like image 121
dira Avatar answered Sep 18 '22 13:09

dira