Bob
Bob

Reputation: 137

Android: Overriding shared element return animation

Here's my situation:

I have Fragment a with a recycler view. Each item has a TextView and an ImageView icon thumbnail. When pressed the app will open up the detail view for this item.

I'm trying to use a shared element with reveal transition starting from the icon thumbnail on the recycler view item to the header image of the detail view. This works, but i don't want the animation to return like it started.

When the user pressed the back button the animation will happen in reverse. I'm trying to override this with the regular default slide transition but I have not succeeded.

What I have tried so far:

<item name="android:windowExitTransition">@android:transition/no_transition</item>
<item name="android:windowSharedElementEnterTransition">@transition/change_image_transform</item>
<item name="android:windowSharedElementExitTransition">@android:transition/no_transition</item> 

I've also tried to override onBackPressed and onPause on the detail activity, but it doesn't seem to work and the animation still happens.

Is there anything i'm missing?

Upvotes: 2

Views: 1495

Answers (1)

crafty
crafty

Reputation: 2730

You need to set the return transition (else by default it will reverse the enter transition):

<item name="android:windowSharedElementReturnTransition">@transition/your_transition</item>

Read more here: https://halfthought.wordpress.com/2014/12/08/what-are-all-these-dang-transitions/

Upvotes: 3

Related Questions