3

我正在用片段 B 替换片段 A 并对其进行动画处理。片段 B 具有RelativeLayoutaTextView和 a ListView。我可以看到片段 B 中的视图是单独动画的,TextView幻灯片的速度与列表项 1 的副标题不同,而列表项 1 的标题和图标立即出现而没有动画,我希望整个视图动画同时,这有可能实现吗?

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    Fragment existing = fragmentManager.findFragmentById(R.id.welcome_content);
    if (existing != null) {                
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            fragmentToLoad.setAllowEnterTransitionOverlap(true);                    
            fragmentToLoad.setEnterTransition(new Slide(Gravity.RIGHT));
        }
        fragmentTransaction.remove(existing);
    }
    fragmentTransaction.add(R.id.welcome_content, fragmentToLoad);
    fragmentTransaction.commitNow();
4

1 回答 1

3

应用于android:transitionGroup="true"的根布局FragmentB

来自文档ViewGroup#setTransitionGroup(boolean)

更改在活动转换期间是否ViewGroup应将其视为单个实体。如果falseViewGroup则不会转换,只有它的孩子。如果true,整个ViewGroup将一起过渡。

于 2017-11-13T18:03:05.407 回答