android - Nested fragments disappear during transition animation -
here's scenario: activity contains fragment a
, in turn uses getchildfragmentmanager()
add fragments a1
, a2
in oncreate
so:
getchildfragmentmanager() .begintransaction() .replace(r.id.fragmentoneholder, new fragmenta1()) .replace(r.id.fragmenttwoholder, new fragmenta2()) .commit()
so far, good, running expected.
we run following transaction in activity:
getsupportfragmentmanager() .begintransaction() .setcustomanimations(anim1, anim2, anim1, anim2) .replace(r.id.fragmentholder, new fragmentb()) .addtobackstack(null) .commit()
during transition, enter
animations fragment b
runs correctly fragments a1 , a2 disappear entirely. when revert transaction button, initialize , display during popenter
animation.
in brief testing, got weirder - if set animations child fragments (see below), exit
animation runs intermittently when add fragment b
getchildfragmentmanager() .begintransaction() .setcustomanimations(enter, exit) .replace(r.id.fragmentoneholder, new fragmenta1()) .replace(r.id.fragmenttwoholder, new fragmenta2()) .commit()
the effect want achieve simple - want exit
(or should popexit
?) animation on fragment a
(anim2) run, animating whole container, including nested children.
is there way achieve that?
edit: please find test case here
edit2: @stevenbyle pushing me keep trying static animations. apparently can set animations on per-op basis (not global whole transaction), means children can have indefinite static animation set, while parent can have different animation , whole thing can committed in 1 transaction. see discussion below , updated test case project.
in order avoid user seeing nested fragments disappearing when parent fragment removed/replaced in transaction "simulate" fragments still being present providing image of them, appeared on screen. image used background nested fragments container if views of nested fragment go away image simulate presence. also, don't see loosing interactivity nested fragment's views problem because don't think want user act on them when in process of being removed(probably user action well).
i've made little example setting background image(something basic).
Comments
Post a Comment