Shared elements animating between fragments

前端 未结 1 1070
猫巷女王i
猫巷女王i 2020-12-12 19:44

I\'m trying to animate 2 simple Views from a selected item in a RecyclerView to a new fragment. I\'ve looked at a lot of examples of animating shared elements from one Acti

相关标签:
1条回答
  • 2020-12-12 20:13

    Finally solved this problem! As it turns out because the view I'm sharing between 2 fragments is a child of another view (RelativeLayout) in the 2nd fragment, you need to add the ChangeTransform transition to your TransitionSet. Apparently ChangeTransform tells the system to remember the views original position in the 1st fragment before animating to the new position in the 2nd fragment. Here is my updated transitionSet. I'll also clean up my test project code a bit and make a final push to bitbucket in case it will help others after me. Thanks for all the help with this one Alex and thank you to @George-mount for answering someones similar question that dropped the hint to me for this solution.

    <?xml version="1.0" encoding="utf-8"?>
    
    <transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
        <changeTransform/>
        <changeBounds/>
    </transitionSet>
    

    https://bitbucket.org/brockoli/fragmentsharedelements

    0 讨论(0)
提交回复
热议问题