android - makeSceneTransitionAnimation when opening an activity from an intent from a button within a fragment -
i opening activity screen on-click of fragment button. trying make button move fragment screen activity screen via makescenetransitionanimation. not animating . how can open activity intent fragment , have animation going. appreciate help.
public class listfragment extends fragment { floatingactionbutton fab; @nullable @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { r.layout.fragment, container, false); } @override public void onactivitycreated(@nullable bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); fab.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent = new intent(getactivity(), mainactivity.class); i.putextra("title", "title"); activityoptionscompat options = activityoptionscompat.makescenetransitionanimation(getactivity(), fab, "image"); activitycompat.startactivity(getactivity(), i, options.tobundle()); } }); }
if see documentation:
/** * create activityoptions transition between activities using cross-activity scene * animations. method carries position of multiple shared elements started * activity. position of first element in sharedelements * used epicenter exit transition. position of associated * shared element in launched activity epicenter of entering transition. * * <p>this requires {@link android.view.window#feature_content_transitions} * enabled on calling activity cause exit transition. same must in * called activity entering transition.</p> * @param activity activity window contains shared elements. * @param sharedelements names of shared elements transfer called * activity , associated views. views must each have * unique shared element name. * @return returns new activityoptions object can use * supply these options options bundle when starting activity. */ public static activityoptionscompat makescenetransitionanimation(activity activity, pair<view, string>... sharedelements) {
so have do
activityoptionscompat options = activityoptionscompat.makescenetransitionanimation(getactivity(), new pair<>(fav, "image")); activitycompat.startactivity(getactivity(), i, options.tobundle());
Comments
Post a Comment