Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8116541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:52:11+00:00 2026-06-06T03:52:11+00:00

I have an android application and while switching between two activities I want to

  • 0

I have an android application and while switching between two activities I want to apply 3D transition… I know the method overridePendingTransition() but it does not have any animation for 3d.. So how it can be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:52:13+00:00Added an answer on June 6, 2026 at 3:52 am

    I had used 3D Cubic Transition between activities.Credit goes to Robert Heim who is developer of this program.

    Below is snippet

    Activity1.java

    package org.vipul;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class Activity1 extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity1);
    
            Button switchActivityBtn = (Button) findViewById(R.id.bSwitchActivity);
            switchActivityBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    animatedStartActivity();
                }
            });
        }
    
        @Override
        protected void onResume() {
            // animateIn this activity
            ActivitySwitcher.animationIn(findViewById(R.id.container),
                    getWindowManager());
            super.onResume();
        }
    
        private void animatedStartActivity() {
            // we only animateOut this activity here.
            // The new activity will animateIn from its onResume() - be sure to
            // implement it.
            final Intent intent = new Intent(getApplicationContext(),
                    Activity2.class);
            // disable default animation for new intent
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            ActivitySwitcher.animationOut(findViewById(R.id.container),
                    getWindowManager(),
                    new ActivitySwitcher.AnimationFinishedListener() {
                        @Override
                        public void onAnimationFinished() {
                            startActivity(intent);
                        }
                    });
        }
    }
    

    Activity2.java

    package org.vipul;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class Activity2 extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity2);
    
            Button switchActivityBtn = (Button) findViewById(R.id.bSwitchActivity);
            switchActivityBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    animatedStartActivity();
                }
            });
        }
    
        @Override
        protected void onResume() {
            // animateIn this activity
            ActivitySwitcher.animationIn(findViewById(R.id.container),
                    getWindowManager());
            super.onResume();
        }
    
        private void animatedStartActivity() {
            // we only animateOut this activity here.
            // The new activity will animateIn from its onResume() - be sure to
            // implement it.
            final Intent intent = new Intent(getApplicationContext(),
                    Activity1.class);
            // disable default animation for new intent
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            ActivitySwitcher.animationOut(findViewById(R.id.container),
                    getWindowManager(),
                    new ActivitySwitcher.AnimationFinishedListener() {
                        @Override
                        public void onAnimationFinished() {
                            startActivity(intent);
                        }
                    });
        }
    }
    

    ActivitySwitcher.java

    package org.vipul;
    
    import android.view.Display;
    import android.view.View;
    import android.view.WindowManager;
    import android.view.animation.AccelerateInterpolator;
    import android.view.animation.Animation;
    
    /**
     * This ActivitySwitcher uses a 3D rotation to animate an activity during its
     * start or finish.
     * 
     * see: http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-
     * animation-activityswitcher/
     * 
     * @author Robert Heim
     * 
     */
    public class ActivitySwitcher {
    
        private final static int DURATION = 300;
        private final static float DEPTH = 400.0f;
    
        /* ----------------------------------------------- */
    
        public interface AnimationFinishedListener {
            /**
             * Called when the animation is finished.
             */
            public void onAnimationFinished();
        }
    
        /* ----------------------------------------------- */
    
        public static void animationIn(View container, WindowManager windowManager) {
            animationIn(container, windowManager, null);
        }
    
        public static void animationIn(View container, WindowManager windowManager,
                AnimationFinishedListener listener) {
            apply3DRotation(90, 0, false, container, windowManager, listener);
        }
    
        public static void animationOut(View container, WindowManager windowManager) {
            animationOut(container, windowManager, null);
        }
    
        public static void animationOut(View container,
                WindowManager windowManager, AnimationFinishedListener listener) {
            apply3DRotation(0, -90, true, container, windowManager, listener);
        }
    
        /* ----------------------------------------------- */
    
        private static void apply3DRotation(float fromDegree, float toDegree,
                boolean reverse, View container, WindowManager windowManager,
                final AnimationFinishedListener listener) {
            Display display = windowManager.getDefaultDisplay();
            final float centerX = display.getWidth() / 2.0f;
            final float centerY = display.getHeight() / 2.0f;
    
            final Rotate3dAnimation a = new Rotate3dAnimation(fromDegree, toDegree,
                    centerX, centerY, DEPTH, reverse);
            a.reset();
            a.setDuration(DURATION);
            a.setFillAfter(true);
            a.setInterpolator(new AccelerateInterpolator());
            if (listener != null) {
                a.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                    }
    
                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }
    
                    @Override
                    public void onAnimationEnd(Animation animation) {
                        listener.onAnimationFinished();
                    }
                });
            }
            container.clearAnimation();
            container.startAnimation(a);
        }
    }
    

    Rotate3dAnimation.java

    package org.vipul;
    
    import android.graphics.Camera;
    import android.graphics.Matrix;
    import android.view.animation.Animation;
    import android.view.animation.Transformation;
    
    /**
     * An animation that rotates the view on the Y axis between two specified
     * angles. This animation also adds a translation on the Z axis (depth) to
     * improve the effect.
     */
    public class Rotate3dAnimation extends Animation {
        private final float mFromDegrees;
        private final float mToDegrees;
        private final float mCenterX;
        private final float mCenterY;
        private final float mDepthZ;
        private final boolean mReverse;
        private Camera mCamera;
    
        /**
         * Creates a new 3D rotation on the Y axis. The rotation is defined by its
         * start angle and its end angle. Both angles are in degrees. The rotation
         * is performed around a center point on the 2D space, definied by a pair of
         * X and Y coordinates, called centerX and centerY. When the animation
         * starts, a translation on the Z axis (depth) is performed. The length of
         * the translation can be specified, as well as whether the translation
         * should be reversed in time.
         * 
         * @param fromDegrees
         *            the start angle of the 3D rotation
         * @param toDegrees
         *            the end angle of the 3D rotation
         * @param centerX
         *            the X center of the 3D rotation
         * @param centerY
         *            the Y center of the 3D rotation
         * @param reverse
         *            true if the translation should be reversed, false otherwise
         */
        public Rotate3dAnimation(float fromDegrees, float toDegrees, float centerX,
                float centerY, float depthZ, boolean reverse) {
            mFromDegrees = fromDegrees;
            mToDegrees = toDegrees;
            mCenterX = centerX;
            mCenterY = centerY;
            mDepthZ = depthZ;
            mReverse = reverse;
        }
    
        @Override
        public void initialize(int width, int height, int parentWidth,
                int parentHeight) {
            super.initialize(width, height, parentWidth, parentHeight);
            mCamera = new Camera();
        }
    
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            final float fromDegrees = mFromDegrees;
            float degrees = fromDegrees
                    + ((mToDegrees - fromDegrees) * interpolatedTime);
    
            final float centerX = mCenterX;
            final float centerY = mCenterY;
            final Camera camera = mCamera;
    
            final Matrix matrix = t.getMatrix();
    
            camera.save();
            if (mReverse) {
                camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
            } else {
                camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
            }
            camera.rotateY(degrees);
            camera.getMatrix(matrix);
            camera.restore();
    
            matrix.preTranslate(-centerX, -centerY);
            matrix.postTranslate(centerX, centerY);
        }
    }
    

    Activity1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#003300"
        android:orientation="vertical" >
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello" />
    
        <Button
            android:id="@+id/bSwitchActivity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="switch activity" />
    
    </LinearLayout>
    

    Activity2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <Button
            android:id="@+id/bSwitchActivity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="back" />
    
    </LinearLayout>
    

    Manifest entries

            <activity
                android:name=".Activity1"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name=".Activity2"
                android:label="Activity 2" >
            </activity>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an Android application. I have a database table and I want to
I want to Reading Color from Android Application. Here I have developed one Application,
I have a weird problem. While running my Android application, I receive Exception: java.lang.ClassCastException:
I'm building the android application but I'm fed up while I'm designing my app
I have created a ProgressDialog in my android application. But the problem I am
I am creating an android application but while(if?) server is not found, it will
I have an android application that is running. After a while when user quits
I have developed a android application which I want to publish to market. I
I'm trying to write an android application that has two main activities: login screen
I have an android application that has a button which I want to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.