This is how my fragment to fragment transition looks like Here's the code:
//Launch Fragment
override fun onClick(v: View?) {
when (v) {
main_sort -> {
val extras = FragmentNavigatorExtras(main_sort to "fragment2")
findNavController().navigate(
R.id.action_dashboardFragment_to_barsFragment,
null,
null,
extras
)
}
}
//Target Fragment
override fun onCreate(savedInstanceState: Bundle?) {
sharedElementEnterTransition = MaterialContainerTransform().apply {
fadeMode = MaterialContainerTransform.FADE_MODE_CROSS
duration = 500
}
super.onCreate(savedInstanceState)
}
For some reason, I had to switch to activity this is how my fragment to activity transition is looking
//launch fragment
override fun onClick(v: View?) {
when (v) {
main_sort -> {
val options =
ActivityOptions.makeSceneTransitionAnimation(requireActivity(), main_sort, "fragment2")
val intent = Intent(requireContext(), SortingActivity::class.java)
startActivity(intent,options.toBundle())
}
}
}
//target activity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.fragment_bars)
val bounds = ChangeBounds()
bounds.duration = 500
window.sharedElementEnterTransition = bounds
as you can see the animation from fragment to activity is weird and doesn't feel as good as the fragment to fragment one, also the exit animation is flickery, and the activity just suddenly changes into image not as smooth as it should be. How can I achieve that fragment to fragment transition in fragment to activity...

