/** * An example of adding these transitions to a Fragment. This simple * version just applies opposite transitions to any Fragment whether it is * entering or exiting view. You can also inspect the transit mode parameter * (i.e. TRANSIT_FRAGMENT_OPEN, TRANSIT_FRAGMENT_CLOSE) in combination to do * different animations for, say, adding a fragment versus popping the back stack. * * Transactions without an explicit transit mode set, in this example, will not * animate. Allowing the initial fragment add, for example, to simply appear. */ public class ExampleFragment extends Fragment implements View.OnClickListener { /** ...Remaining Fragment Code... */ @Override public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) { if (transit == 0) { return null; } //Target will be filled in by the framework return enter ? ObjectAnimator.ofFloat(null, new XFractionProperty(), 1f, 0f) : ObjectAnimator.ofFloat(null, new XFractionProperty(), 0f, -1f); } }