1

I'm creating an android application. Now i want to open a new activity with zooming transition im using the following codes to acheive that but its not working.

private void centerAndZoomView( View view)
    {
        LinearLayout root = (LinearLayout) findViewById( R.id.top_root );
        DisplayMetrics dm = new DisplayMetrics();
        this.getWindowManager().getDefaultDisplay().getMetrics( dm );
        int statusBarOffset = dm.heightPixels - root.getMeasuredHeight();

        int originalPos[] = new int[2];
        view.getLocationOnScreen( originalPos );

        int xDest = dm.widthPixels/2;
        xDest -= (view.getMeasuredWidth()/2);
        int yDest = dm.heightPixels/2 - (view.getMeasuredHeight()/2) - statusBarOffset;

        TranslateAnimation anim = new TranslateAnimation( 0, xDest - originalPos[0] , 0, yDest - originalPos[1] );

        Animation scale
          = new ScaleAnimation(1.0f,root.getMeasuredWidth()/view.getMeasuredWidth() , 1.0f, root.getMeasuredHeight()/view.getMeasuredHeight(),
                               Animation.RELATIVE_TO_SELF, 0.5f,
                               Animation.RELATIVE_TO_SELF, 0.5f);


        scale.setInterpolator(new AccelerateInterpolator());

        AnimationSet set = new AnimationSet(true);

        set.addAnimation(anim);
        set.addAnimation(scale);


        set.setFillAfter(false);

        set.setDuration(7000);
        set.start();


        view.startAnimation(set);
        set.setAnimationListener(new AnimationListener()
        {
            @Override
            public void onAnimationStart(Animation animation){}

            @Override
            public void onAnimationRepeat(Animation animation){}

            @Override
            public void onAnimationEnd(Animation animation)
            {
                callIntent();


            }
        });

    }

Basically I want the effect that the new activity with zooming effect. But for now my current clicked button only zooming. How can I achieve that? please help me to solve this.

swatz
  • 55
  • 11
  • Check this out: http://stackoverflow.com/questions/20690764/overridependingtransition-for-sliding-activities-in-and-out-smoothly – activesince93 Nov 26 '15 at 12:54

1 Answers1

0
startActivity(intent);
overridePendingTransition(animationIn,animationOut);

zoom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3" >
</scale>

zoom_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" >
</scale>

Kishan Soni
  • 816
  • 1
  • 6
  • 19
  • Hi kishan,i dn't need after launching of new actvity and then zoom effect..i need while launching new actvity itself it should come in a zooming transition..(like circularreveal effect)..but for me it should be in rectangular way. – swatz Nov 27 '15 at 04:38