android - Fragment ReenterTransition not working. Need help clarifying the various Fragment transitions -
i implementing fragment transition animations between items in recyclerview, , fragment showing details of clicked item. in other words relatively common...
"click on card in list , expands detailed view while rest of list disappears"
...kind of thing.
the transition recyclerview item detailed view working fine. shared elements of item transitioning new state while rest of recyclerview items fade away.
however, when backstack popped shared elements transition old state, other recyclerview items not fade in. appear instantly @ start of animation instead, can see in screen video
the activity handles quite few fragments, transaction in following generalized method:
@targetapi(build.version_codes.lollipop) public void setfragment(int fragid, bundle args, list<pair> transitionviews, string tag, int containerid) { // setup new fragment , transaction fragment newfragment = fragmentfactory.newfragment(fragid, args); fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction(); fragmenttransaction.replace(containerid, newfragment, tag); fragmenttransaction.addtobackstack(tag); if (build.version.sdk_int >= build.version_codes.lollipop && transitionviews != null) { // add shared elements (int = 0; < transitionviews.size(); i++) { final pair pair = transitionviews.get(i); fragmenttransaction.addsharedelement((view) pair.first, (string) pair.second); } // setup transitions transition transitionmove = transitioninflater.from(this).inflatetransition(android.r.transition.move); transition transitionfade = transitioninflater.from(this).inflatetransition(android.r.transition.fade); // transitionfade.setduration(500); // slow down transition see what's happening // apply relevant transitions each fragment newfragment.setsharedelemententertransition(transitionmove); newfragment.setentertransition(transitionfade); newfragment.setexittransition(transitionfade); mcurrentfragment.setexittransition(transitionfade); mcurrentfragment.setreentertransition(transitionfade); mcurrentfragment.setsharedelementreturntransition(transitionmove); } fragmenttransaction.commit(); } - i have tried playing allowing/disallowing transition overlap on enter/return.
- i have tried playing various transition setting methods fragments.
- i have read through loads of blogs , questions on topic.
i found http://www.androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html blog on topic, , brockoli's sample code helpful, have been unable solve problem.
perhaps problem understanding of each transition for?
here's how understand it.
my mcurrentfragment , newfragment have 5 different transition setters each:
setsharedelemententertransitionsets transition used shared elements transferred content scene.setsharedelementreturntransitionsets transition used shared elements transferred during pop of stack.setentertransitionsets transition used move views initial scene.setexittransitionsets transition used move views out of scene when fragment removed, hidden, or detached when not popping stack.setreentertransitionsets transition used move views in scene when returning due popping stack.
when setfragment method called, animation played transitioning mcurrentfragment newfragment following properties:
- the
newfragmentsharedelemententertransition defines how shared elements transitionnewfragment.
(in case clicked item's cardview expands , 1 of textview's contains moved) - the
newfragmententertransition defines how remainingnewfragmentchild views not shared elements transition onto screen.
(in case toolbar fades in @ bottom of screen. toolbar fading in behind exiting recyclerview. there way swap it's in front?) - the
mcurrentfragmentexittransition defines howmcurrentfragmentchild views not shared elements transition off of screen.
(in casemcurrentfragmentcontains recyclerview, effect rest of recyclerview elements fade away in background)
when backstack popped expect following occur:
- the sharedelementreturntransition
mcurrentfragmentdefines how shared elements transitionmcurrentfragment.
(in case cardview contracts down recyclerview item size , textview contains moved back). - the exittransition
newfragmentdefines hownewfragmentchild views not shared elements transition off of screen.
(in case bottom toolbar fades out) - the reentertransition
mcurrentfragmentdefines how remainingmcurrentfragmentchild views not shared elements transition onto screen.
(in case other recyclerview items should fade in, not happening. instantly visible behind transitioning shared elements).
have misunderstood anything?
Comments
Post a Comment