0

I've been learning about material transitions, following this guide. I have a little test app where I'm trying this out.

My activity code looks like this:

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.transition.Slide;
import android.view.View;

public class TransitionsHome extends AppCompatActivity {

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

    public void slide(View view){
        //Create a slide object, then set it as the exit transition
        Slide slide = new Slide();
        slide.setDuration(1000);
        getWindow().setExitTransition(slide);

        startActivity(new Intent(this, SlideActivity.class));
    }

I have a button that calls slide() when it's pressed.

The problem is, it's changing to the proper activity, but it isn't animating at all. Why doesn't this work?

1 Answers1

2

Call StartActivity like this:

startActivity(intent,ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
TheoKanning
  • 1,631
  • 11
  • 20
  • @uestcfei So do I have to inflate the XML and call `overridePendingAnimation` and everything to be backwards-compatible? –  Jan 25 '16 at 14:00