1

When change from Ativity A to Activity B and viceversa I want that only Activity B to animate, but in my case Activity A also animates.(leaving a blank space in the left of the screen) Activity B animation is working well, my problem is with the animation of Activity A.(which shouldn't exists). I have set

//Activity B
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    setContentView(R.layout.mylayout); 
      //..........
  }

only in Activity B. I want that Activity A never animates or disappears from the screen.

I fixed the reverse animation(change from Activity B to Activity A) in this way:

//Activity B
@Override
public void onPause(){
    super.onPause();
    overridePendingTransition(0, R.anim.fadeout);
}

This works good, so, now the problem is only with the change from Activity A to Activity B, I would like the same behave of Activity A(just stay, no animation). But If I try overridePendingTransition(R.anim.fadein, 0); in onCreate(), Activity A disappears from the screen.

fadein.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromXDelta="100%p" android:toXDelta="0%p" android:duration="1000"/>

fadeout.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/accelerate_interpolator">
        <translate android:fromXDelta="0%p" android:toXDelta="100%p" android:duration="1000"/>
</set>

In the first image is what I get now, in the second image is what I want to get.

enter image description here

AlexAndro
  • 1,918
  • 2
  • 27
  • 53

1 Answers1

9

Try this.

staystill.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"
 />
Renjith
  • 5,783
  • 9
  • 31
  • 42
  • where should I place this animation? – AlexAndro Feb 14 '13 at 09:44
  • I mean, how to use it, where to call it? Should I replace any of my animation with this one? Should I set it to `Activity A`? Please tell me. – AlexAndro Feb 14 '13 at 09:49
  • `overridePendingTransition(R.anim.fadein,R.anim.staystill);` and then set `android:duration="1000"` in `staystill.xml` solves the problem. – AlexAndro Feb 14 '13 at 10:10
  • I like your solution. But still I am getting black screen while animating new activitiy. Please provide solution to remove black screen. – Maulik Patel Jun 14 '17 at 11:00