Material-Animations icon indicating copy to clipboard operation
Material-Animations copied to clipboard

Not Working!!

Open s1mar opened this issue 8 years ago • 11 comments

I'm doing this,it is not working for me,any pointers guys

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

    @TargetApi(21)
    private void setEnterTransition(){

        Fade fade_transition = new Fade();
        fade_transition.setDuration(1000);
        getWindow().setEnterTransition(fade_transition);
    }

    @TargetApi(21)
    private void setExitTransition(){

        Slide slide_transition = new Slide();
        slide_transition.setDuration(1000);
        getWindow().setExitTransition(slide_transition);
    }

s1mar avatar Jan 31 '17 07:01 s1mar

Can you please provide more info? What is happening? What do you expect to happen?

lgvalle avatar Feb 11 '17 19:02 lgvalle

My guess is that you are missing this in your styles.xml

<item name="android:windowContentTransitions">true</item

MarijanGazica avatar Feb 13 '17 15:02 MarijanGazica

@MarijanGazica I was setting the basic slide and fade transitions programmatically(no xml),but they aren't working,I see no effect

s1mar avatar Feb 21 '17 03:02 s1mar

@s1mar even though you did it programmatically, you still, from my experience, need to add that flag. Also, which version of Android is running on your test device(s)?

MarijanGazica avatar Feb 21 '17 08:02 MarijanGazica

@lgvalle @MarijanGazica the same happened with me. I have set animation via program way, setup flag <item name="android:windowContentTransitions">true</item and nothing. Either nexus 5x 7.0 or emulator 6p 6.0

iamtodor avatar Mar 05 '17 08:03 iamtodor

Hello @s1mar I think you have to start the activity with this code

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this);

startActivity(intent, options.toBundle());

Davids89 avatar Apr 19 '17 10:04 Davids89

@Davids89 Hey, I'm having the same issues, I got the enter animation to work by adding the startActivity parameter but my exit transitions still don't work. Do you know if there is anything else necessary?

RichyHBM avatar May 20 '17 21:05 RichyHBM

@Davids89 its working with this solution, but on my back press my activity is full grey, without UI

pcg92 avatar Jun 01 '17 08:06 pcg92

@Davids89 ` @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); setupWindowAnimations(); }

private void setupWindowAnimations() {
    Slide slide =(Slide) TransitionInflater.from(this).inflateTransition(R.transition.activity_slide);
    getWindow().setExitTransition(slide);
}

@Override
protected void onStart() {
    super.onStart();
    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(Splash.this);
    Intent intent = new Intent(this,Splash2.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(intent,options.toBundle());
}`

still not working.

@pcegarra try adding the FLAG_ACTIVITY_NO_HISTORY, this will prevent your activity from going into the back stack,hope it works for you

s1mar avatar Jun 18 '17 15:06 s1mar

I've followed every instruction available on the internet and still couldn't get it to work. What I've observed is that on a cold start,you just cant see the enter transition of our launcher activity.Also, ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(Splash.this); Intent intent = new Intent(this,Splash2.class); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); startActivity(intent,options.toBundle());

if you use a transition activity code,android simply seems to skip through the transition effects and launch the next activity. I believe there is something that you're forgetting to mention or tell us @lgvalle

s1mar avatar Jun 19 '17 09:06 s1mar

I'm having the same issues,setExitTransition(Slide)not working,but the enter return and reenter is working

public class OneActivity extends AppCompatActivity implements View.OnClickListener {
    private Button mBack;
    private Button mNext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_one);
        setupWindowAnimations();
        mBack = findViewById(R.id.btn_back);
        mNext = findViewById(R.id.btn_next);
        mBack.setOnClickListener(this);
        mNext.setOnClickListener(this);
    }

    private void setupWindowAnimations() {
        Slide enter = new Slide();
        enter.setDuration(DURATION);
        enter.setSlideEdge(Gravity.RIGHT);
        enter.setInterpolator(new DecelerateInterpolator());

        Slide exit = new Slide();
        exit.setDuration(DURATION);
        exit.setSlideEdge(Gravity.LEFT);
        exit.setInterpolator(new DecelerateInterpolator());

        Slide reenter = new Slide();
        reenter.setSlideEdge(Gravity.LEFT);
        reenter.setDuration(DURATION);
        reenter.setInterpolator(new DecelerateInterpolator());

        Slide returnT = new Slide();
        returnT.setDuration(DURATION);
        returnT.setSlideEdge(Gravity.RIGHT);
        returnT.setInterpolator(new DecelerateInterpolator());

        getWindow().setReenterTransition(reenter);
        getWindow().setEnterTransition(enter);
        getWindow().setReturnTransition(returnT);
        getWindow().setExitTransition(exit);
        getWindow().setAllowEnterTransitionOverlap(true);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                finishAfterTransition();
                break;
            case R.id.btn_next:
                Intent i = new Intent(this, TowActivity.class);
                startActivity(i, ActivityOptionsCompat.makeSceneTransitionAnimation(this).toBundle());
                break;
            default:

        }
    }
}

please help me,thanks!

daleige avatar Mar 31 '20 09:03 daleige