Friday, March 30, 2012

[android-developers] Merging Bounce animation with sliding animation (bounce like zoom out/zoom in)

I need to mix two animations between my activity switching.

I already have slide-in/out left/right animations in place but I want
to give a effect of Z-axis bounce to the new activity coming in focus.

It should look give the following effect: When next activity is
called, current activity is slide out with new activity head to head
and the new activity should be 80% of the original while sliding in to
the focus. When new activity is on the screen, it should zoom out to
120% and immediately resize to 100%

so the effect should look like a bounce effect towards z axis after
slide animation is finished.

Here is some of my code.

Main activity

public void onClickPrev(View view) {
Intent intent = new Intent(this, SecondActivity.class);
startActivityForResult(intent, 1);
overridePendingTransition(R.anim.slide_in_left,
R.anim.slide_out_right);
}
public void onClickNext(View view) {
Intent intent = new Intent(this, SecondActivity.class);
startActivityForResult(intent, 2);
overridePendingTransition(R.anim.slide_in_right,
R.anim.slide_out_left);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if(requestCode == 1)
overridePendingTransition(R.anim.slide_in_left,
R.anim.slide_out_right);
if(requestCode == 2)
overridePendingTransition(R.anim.slide_in_right,
R.anim.slide_out_left);
}
Second activity code

public void onClickPrev(View view) {
Intent intent = new Intent(this,
TransitionAnimationActivity.class);
startActivityForResult(intent, 1);
overridePendingTransition(R.anim.slide_in_left,
R.anim.slide_out_right);
}
public void onClickNext(View view) {
Intent intent = new Intent(this,
TransitionAnimationActivity.class);
startActivityForResult(intent, 2);
overridePendingTransition(R.anim.slide_in_right,
R.anim.slide_out_left);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if(requestCode == 1)
overridePendingTransition(R.anim.slide_in_left,
R.anim.slide_out_right);
if(requestCode == 2)
overridePendingTransition(R.anim.slide_in_right,
R.anim.slide_out_left);
}
slide_in_left.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%" />
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%" />
slide_out_left.xml

<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%" />
slide_out_right.xml

<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%" />

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment