I have two activities.. Activity A and Activity B.
When I start Activity B from Activity A. I want Activity A to be static to its positions and animations to show up only for Activity B. How do i achieve this using overridingPendingTransition?
This below code is called from ActivityA when button is clicked as follows :
Activity A:
public void onClick(View v) {
super.onClick(v);
if (v.getId() == R.id.button) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), MyProfileActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
}
Activity A also slides with Activity B. How to stop the animation of Activity A and enable animations of Activity B alone?
slide_out_up xml is as follows :
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="400"
android:fromYDelta="0%"
android:toYDelta="-100%" />
<alpha
android:duration="400"
android:fromAlpha="1"
android:toAlpha="0" />
</set>
slide_in_up :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="400"
android:fromYDelta="100%"
android:toYDelta="0%" />
<alpha
android:duration="400"
android:fromAlpha="0"
android:toAlpha="1" />
</set>
The simplest way you could go is pass 0 for the second parameter, instead of R.anim.slide_out_up. However, this usually leads to Activity A showing up as a black screen behind Activity B, so as a workaround you can provide any animation that does nothing - e.g. translation from 0% to 0%.
Need to use this.
slide_in_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="400"
android:fromXDelta="-100%"
android:toXDelta="0%" />
<alpha
android:duration="400"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
slide_in_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="400"
android:fromXDelta="100%"
android:toXDelta="0%" />
<alpha
android:duration="400"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With