-3

I would like to add some transition effect between the activities I have tried overridePendingtransition but I did not get any change.I am using android 2.3.6 . I just need left to tight transition effect. What I've to do.?

       @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);                                                              getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    overridePendingTransition ( 0 , R.anim.grow_from_top );

    setContentView(R.layout.aboutus);


              grow_from_top.xml
             <?xml version="1.0" encoding="utf-8"?>
              <set xmlns:android="http://schemas.android.com/apk/res/android">
        <scale
    android:fromXScale="0.3" android:toXScale="1.0"
    android:fromYScale="0.3" android:toYScale="1.0"
    android:pivotX="50%" android:pivotY="100%"
    android:duration="@android:integer/config_shortAnimTime"
     />
         <alpha
    android:interpolator="@android:anim/decelerate_interpolator"
    android:fromAlpha="0.0" android:toAlpha="1.0"
    android:duration="@android:integer/config_shortAnimTime"
         />
        </set>
devian
  • 123
  • 5
  • 17

1 Answers1

1

The transition effect needs to be called upon calling the Activity to change to.

So, in the previous Activity, on a "Continue" Button or however you call the next Activity:

@Override
    public void onClick(View v) {
        Intent someIntent= new Intent(this, NextActivity.class);            
        startActivity(someIntent);
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }

And the animation effect (slide_out_left):

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<translate
    android:duration="200"
    android:fromXDelta="0%"
    android:fromYDelta="0%"
    android:toXDelta="-100%"
    android:toYDelta="0%" />
</set>

slide_in_right.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<translate
    android:duration="200"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>

In this case, the XML files need to be placed in /res/anim/. To reverse the directions, you only need to change the fromXDelta and toXDelta values.

Lennart
  • 9,657
  • 16
  • 68
  • 84