MightySeal
MightySeal

Reputation: 2315

Combine activity custom animation and scene transition animation

Is it possible to combine ActivityOptionsCompat.makeCustomAnimation() and ActivityOptionsCompat.makeSceneTransitionAnimation() ? I want to acheive the following Activity change effect:

  1. One view stays on the screen
  2. Other views from old activity slide out
  3. Views from the new activity fade in

I can use points 1 and 2, 3 separately, is there a way to use them simultaneously maybe using different method or something?

Upvotes: 4

Views: 1072

Answers (1)

George Mount
George Mount

Reputation: 20926

The ActivityOptionsCompat.makeSceneTransitionAnimation() should do all of what you want in L+. In your calling Activity's style add:

<item name="android:windowExitTransition">@android:transition/slide_right</item>

and in your called Activity's style add:

<item name="android:windowEnterTransition">@android:transition/fade</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>

You may want to do this as well:

How do I prevent the status bar and navigation bar from animating during an activity scene animation transition?

Upvotes: 5

Related Questions