I have three fragments inside a ViewPager in an activity, I want to achieve shared element transition from one of the fragments to another activity. The transition is from a recycler view which is inside a fragment which is inside a viewpager which is inside an Activity Activity->ViewPager->Fragment->Recyclerview
I have searched each every places internet but there are info only about shared element transition from one fragment to another and one activity to another. There is no content about transition from fragment to activity
holder.poster.setTransitionName("posterX");
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) con,holder.poster,holder.poster.getTransitionName());
Log.e("Animation", "Success");
//startActivity((Activity) con,intent,options.toBundle());
c.startActivity(intent,options.toBundle());
On using the above code the second activity is launched but nothing is visible, For example the second activity contains a FAB which when clicked youtube is launched. I know where the FAB is so when i click blindly, youtube launched correctly but nothing is visible in second activity
D/ViewRootImpl: changeCanvasOpacity: opaque=true
Its one of the logcats. I think this must be the problem!!
Android also supports these shared elements transitions: changeBounds - Animates the changes in layout bounds of target views. changeClipBounds - Animates the changes in clip bounds of target views. changeTransform - Animates the changes in scale and rotation of target views.
Can I go from fragment to activity Android? You can add your fragment to the activity's view hierarchy either by defining the fragment in your activity's layout file or by defining a fragment container in your activity's layout file and then programmatically adding the fragment from within your activity.
The Fragment API provides two ways to use motion effects and transformations to visually connect fragments during navigation. One of these is the Animation Framework, which uses both Animation and Animator . The other is the Transition Framework, which includes shared element transitions.
Yeah you can use same fragment in different activities. Create a fragment_container view in all activities that you need to call the fragment. Then call the fragment into that container .
I had the same problem, I couldn't find anything that helps sorry, but maybe you should reconsider why would you need a Fragment to Activity relation when you could work with a Fragment to Fragment or Activity to Activity relation.
I've solved my problem that way changing my code to a Fragment to Fragment relation and there is plenty documentation and examples about that Shared Element Transitions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With