Nested fragments disappear during transition animation

后端 未结 16 1713
广开言路
广开言路 2020-11-29 15:50

Here\'s the scenario: Activity contains fragment A, which in turn uses getChildFragmentManager() to add fragments A1 and A2

16条回答
  •  一生所求
    2020-11-29 16:16

    In order to avoid the user seeing the nested fragments disappearing when the parent fragment is removed/replaced in a transaction you could "simulate" those fragments still being present by providing an image of them, as they appeared on the screen. This image will be used as a background for the nested fragments container so even if the views of the nested fragment go away the image will simulate their presence. Also, I don't see loosing the interactivity with the nested fragment's views as a problem because I don't think you would want the user to act on them when they are just in the process of being removed(probably as a user action as well).

    I've made a little example with setting up the background image(something basic).

提交回复
热议问题