Reputation: 389
I wanna make a transition from Activity A to activity B via onClickListener on Button(btn). But I want to make a transition that looks like a Activity B window is pushing the Activity A window in a slide-like motion.
I tried making it with a this line of code, but I can't get it quite right.
My Activity class code:
overridePendingTransition(R.anim.open_translate, R.anim.activity_close_scale);
open_translate:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:duration="800"
android:fromXDelta="100%"
android:toXDelta="0%"></translate>
close_scale:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="800"
android:fromXDelta="100%"
android:toXDelta="0%"></translate>
<alpha
android:duration="300"
android:fromAlpha="1"
android:toAlpha="0.8"/>
Upvotes: 1
Views: 1368
Reputation: 433
This is code for open_translate :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="100%" android:toXDelta="0"/>
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="1.0" />
</set>
This is code for close_scale:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="0" android:toXDelta="-100%p"/>
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="1.0" />
</set>
Upvotes: 2