question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addSharedElement not work when using `add`

See original GitHub issue
                Fragment fragment = ViewerFragment.newInstance(diary.getPhotoUrl());
                fragment.setSharedElementEnterTransition(new ChangeBounds());
                getFragmentManager().beginTransaction()
                        .hide(this)//either using hide or not won't work
                        .add(R.id.container, fragment)// it work when using replace 
                        .addToBackStack("")
                        .addSharedElement(attachPicture, attachPicture.getTransitionName())
                        .commit();

Could you tell me why is that? Because I read the document of addSharedElement, it says:

Used with custom Transitions to map a View from a removed or hidden Fragment to a View from a shown or added Fragment.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DanteAndroidcommented, Mar 16, 2017

I don’t get you. When I use replace it works. The view is always referencing in the old one. I think it’s a bug. Now I use Activity with sharedElement and works well. I think the document is clear enough, so… Don’t you think?

0reactions
PhantomLord72commented, Nov 19, 2018

I have exact issues even with androidX. I have open a bug on issuetracker on google. Anyone have found a workaround?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fragment shared element transition with add() instead of ...
Try this getSupportFragmentManager().beginTransaction() .addSharedElement(myImage, "mytransition") .add(R.id.recycler_view_container, ...
Read more >
Hidden mistakes with Shared Element Transitions - Medium
Call addSharedElement() and add the views that will be shared between screens. Add unique android:transitionName on each view in transition.
Read more >
Android shared element transition not working - Issue Tracker
No back stack working in java code. Shared element transition is showing type Error Required type: androidx.navigation.Navigator.Extras
Read more >
Shared Element Activity Transition | CodePath Android Cliffnotes
Assign a common transition name to the shared elements in both layouts. Use the android:transitionName attribute. ... Note that it doesn't matter if...
Read more >
FragmentTransaction - Android Developers
When running on Android 3.0 or above, this implementation is still used; it does not ... Add a fragment to the associated FragmentManager...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found