androidmaterial-designactivity-transition

Android activity transition does not appear


I have been trying for some months to get an activity transition to work. I have tried a number of approaches, using XML and styles, and code, to no avail. Below is my most recent attempt. Does anyone know why I can't get any transitions to appear?

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    addSlideTransitions();
    setContentView(R.layout.my_activity_layout);
    ....
}

protected void addSlideTransitions()
{
    getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    Slide slide = new Slide();
    slide.setDuration(1000);
    getWindow().setEnterTransition(slide);
    getWindow().setExitTransition(slide);
}

Solution

  • You must start the activity with an ActivityOptions bundle created with makeSceneTransitionAnimation.

    That type of transition also only works when in the same task (as of N).