Skip to content

Instantly share code, notes, and snippets.

@thejakeofink
Last active January 15, 2016 17:32
Show Gist options
  • Save thejakeofink/2146d84b8b6cf5120b77 to your computer and use it in GitHub Desktop.
Save thejakeofink/2146d84b8b6cf5120b77 to your computer and use it in GitHub Desktop.
Example for a simple Scene Transition in Android.
TransitionSet transitionSet = new TransitionSet();
Scene endingScene = Scene.getSceneForLayout(findViewById(R.id.scene_root), int R.id.end_scene, context);
// There are multiple Transition types this is just one example.
// You can also make your own transitions
Transition cb = new ChangeBounds();
cb.addTarget(R.id.scene_target_one);
cb.addTarget(R.id.scene_target_two);
transitionSet.addTransition(cb);
Transition f = new Fade();
f.addTarget(R.id.scene_target_three);
f.setStartDelay(200);
transitionSet.addTransition(f);
transitionSet.setDuration(500);
// You can use whichever Interpolator you would like here.
transitionSet.setInterpolator(new LInearOutSlowInInterpolator());
transitionSet.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
// I usually will do my wire ups for any new UI items in here.
}
@Override
public void onTransitionEnd(Transition transition) {}
@Override
public void onTransitionCancel(Transition transition) {}
@Override
public void onTranistionPause(Transition transition) {}
@Override
public void onTransitionResuem(Transition transition) {}
});
// This is the button that makes it go.
TransitionManager.go(endingScene, transitionSet);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment