小编Wak*_*mad的帖子

getChildFragmentManager()的共享转换不起作用但使用getFragmentManager()

我实现了如下片段:

  1. 保持父片段的活动.使用getSupportFragmentManager()添加Parent片段.
  2. 在父片段中,我使用getChildFragmentManager()和transaction来替换childFragment.
  3. 在childFragment中我再次调用childFragment等等....
  4. 除了共享过渡之外,一切正常.
  5. 如果我使用getFragmentManager()而不是getChildFragmentManager()然后有共享转换,但是没有getChildFragmentManager()的概念.

代码示例如下所示:

/*This code does not show animation*/
getChildFragmentManager()
                .beginTransaction()
                .addSharedElement(transitionView, ViewCompat.getTransitionName(transitionView))
                .replace(R.id.fragment_container, categoryDetailChildFragment)
                .addToBackStack(TAG)
                .commit();
Run Code Online (Sandbox Code Playgroud)

并且显示动画的代码是:

  getFragmentManager()
                .beginTransaction()
                .addSharedElement(transitionView, ViewCompat.getTransitionName(transitionView))
                .replace(R.id.fragment_container, categoryDetailChildFragment)
                .addToBackStack(TAG)
                .commit();
Run Code Online (Sandbox Code Playgroud)

为什么getChildFragmentManager()时没有共享转换?请帮助任何人.

animation android android-fragments

10
推荐指数
1
解决办法
287
查看次数

标签 统计

android ×1

android-fragments ×1

animation ×1