Transition from Activity A to Activity B requires 3D flipping.
Step by Steps
- Get this source code from Android Developer this.
- Before leaving the activity A, play animation (0,90) on root layout of activity A .
- onCreate of activity B, play animation (90,0) on root layout of activity B.
private void applyRotation(float start, final float end) {
// Find the center display as we are rotating the whole page
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
final float centerX = width / 2.0f;
final float centerY = height / 2.0f;
// Create a new 3D rotation with the supplied parameter
// The animation listener is used to trigger the next animation
final Flip3dAnimation rotation = new Flip3dAnimation(start, end, centerX, centerY);
if (end == 0) {
rotation.setDuration(1);
} else {
rotation.setDuration(500);
}
rotation.setFillAfter(true);
rotation.setInterpolator(new AccelerateInterpolator());
rotation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
if (end != 0) {
Intent i = new Intent(ActivityA.this, ActivityB.class);
startActivity(i);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
if (end == 0) {
llRoot.setVisibility(View.INVISIBLE);
}
}
});
llRoot.startAnimation(rotation);
}
No comments:
Post a Comment