【问题标题】:FragmentTransaction animation - show enter fragment above exit fragmentFragmentTransaction 动画 - 在退出片段上方显示进入片段
【发布时间】:2014-03-27 09:08:33
【问题描述】:

当您使用检查动画移位片段(传出片段的持续时间比动画传入片段更长)时,面对片段出现时间动画落在传出片段之下的事实 - 我希望它在传出片段上进行动画处理.谁知道如何达到预期的效果呢?

第一个片段添加:

fragmentManager.beginTransaction().add(R.id.frame_layout_fragments_container, new FragmentHome(), "home").commit();

替换片段:

fragmentManager.beginTransaction().setCustomAnimations(R.anim.forward_show, R.anim.forward_hide, R.anim.back_show, R.anim.back_hide).replace(R.id.frame_layout_fragments_container, fragment, fragmentName).commit();

简单的插图

现在我有:

我需要什么:

【问题讨论】:

  • 你找到答案了吗?我有同样的问题,目前没有解决方案...
  • @PsyCoder 很遗憾无法快速优雅地解决这个问题 - 没有时间不得不为一个片段管理器使用多个容器 - 这肯定是一种不好的做法和肮脏的工作
  • 这个问题是怎么解决的,请多指教

标签: java android animation android-fragments


【解决方案1】:

【讨论】:

  • 不,我想实现当传出和传入片段向一个方向移动时实现它,但是由于传入片段具有更快的动画,并且在事务期间它应该位于顶部传出片段。
【解决方案2】:

我认为您可以尝试以下方法作为解决方法。

fragmentTr.setCustomAnimations(enter, exit);
fragmentTr.hide(currentFragment);
fragmentTr.add(containerId, newFragment, "aTag");
fragmentTr.show(newFragment);
fragmentTr.commit();

不要使用replace()。我尝试了上述方法,并且成功了。 希望这会有所帮助。

【讨论】:

    【解决方案3】:
    ViewCompat.setTranslation(getView, 100.f);
    

    寻找https://stackoverflow.com/a/33816251/6642400

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-11
      • 1970-01-01
      相关资源
      最近更新 更多