switch between activity with rotation animation

Question!

does anybody knows how to launch a new activity with rotation animation?

I'll try to explain what i want to do:

For instance i've looked for android app exemple in skd sample "apidemos" and i've found a class named com.exemple.android.apis.animation.Rotate3dAnimation.java and com.exemple.android.apis.animation.Transition3d.java. These classes allow me to switch between image with rotation effect.

That I would like to know if there is a way to do the same but instead of image, i will be activity (whith new layout).



Answers

This is how we can accomplish this. Suppose we want to switch from Activity A to B. First we will animate activity A then we will start activity B in overridden function "onAnimationFinished". This will ensure that activity B is started only after animation for activity A has finished off.

// we will only animate activity A here.
// The activity B will be animated from its onResume() - be sure to implement it.

final Intent intent = new Intent(getApplicationContext(), B.class);
// disable default animation for new intent
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
//Animate A
ActivitySwitcher.animationOut(findViewById(R.id.A), getWindowManager(), new ActivitySwitcher.AnimationFinishedListener() {
        @Override
        public void onAnimationFinished() {
            // Start activity B
            startActivity(intent);
        }
    });

Now override "onResume" function for activity B

@Override
protected void onResume() {
// animateIn this activity
ActivitySwitcher.animationIn(findViewById(R.id.help_top), getWindowManager());
    super.onResume();
}

You can see here for working example

http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-animation-activityswitcher/comment-page-1/#comment-12025



The window manager doesn't support 3d transformations at this point; since each activity is a window, animations between activities are window animations, so they are limited to what the window manager supports.

By : hackbod


This video can help you solving your question :)
By: admin