android - Changing reenter animation to another item of a list -
android - Changing reenter animation to another item of a list -
i have recyclerview images , when press image app opens activity contains viewpager same images in position of 1 selected.
i've done transition in lollipop share image between activities using supportpostponeentertransition , supportstartpostponedentertransition in called activity wait until viewpager loaded images start transition.
when come in in called activity , when press transitions ok.
the problem i'm facing if move image in viewpager of called activity, when press animates image selected @ beginning, not selected one.
i've been able alter animated image 1 selected in called activity this:
@override public void onbackpressed() { view view = ((imagedetailfragment) adapter.getfragment(viewpager, viewpager.getcurrentitem())).gettransitionview(); viewcompat.settransitionname(view, constants.transition_image); super.onbackpressed(); }
but returning same position of original image in list of calling activity.
how can create image homecoming position in list of calling activity?
the first thing create sure views work without activity transition. is, when homecoming activity viewpager, recyclerview activity should showing view viewpage showing. when phone call viewpager activity, utilize startactivityforresult , utilize result scroll recyclerview right position.
once working, activity transition can made work. know you've given each view in recyclerview different transitionname, right? when bind view, phone call settransitionname , give repeatable name. typically image url or cursor row id or @ worst munged index "image_" + index.
the next thing need set sharedelementcallback both calling activity (exit) , called activity (enter). in each, you're going need override onmapsharedelements callback remap shared element.
@override public void onmapsharedelements(list<string> names, map<string, view> sharedelements) { // assuming 1 shared element, excuse ugly code sharedelements.put(names.get(0), msharedelement); }
here, msharedelement has been set in onactivityreenter in calling (recyclerview) activity , in oncreate , prior finishaftertransition (onbackpressed?) in called (viewpager) activity.
the onactivityreenter gives new functionality case. can @ results there before called activity completes.
android android-5.0-lollipop shared-element-transition activity-transition
Comments
Post a Comment