Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding pending transition with animation object instead of resource id

Is there any way to override the pending transition by passing it actual Animation object instead of an ID to an animation resource?

From

startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);

To

startActivity(intent);
overridePendingTransition(new MyFadeInAnimation(), new MyFadeOutAnimation());

If not, is there a way for me to manually register an animation resource (and attain an ID) programatically?

I really do not want to define the activity transition animations as XML for other reasons.

like image 380
Herman Schoenfeld Avatar asked Oct 15 '13 11:10

Herman Schoenfeld


1 Answers

So one way to do this is to use Fragments. Set overridePendingTransition(0,0); for the Activity. and then in the Fragment, override onCreateAnimator() or if using the old animations, use android.support.v4.app.Fragment and override onCreateAnimation().

like image 77
Paul Burke Avatar answered Nov 15 '22 00:11

Paul Burke