同时使视图动画化的片段转换

3
我正在将片段A替换为片段B并进行动画处理。片段B具有一个带有TextViewListViewRelativeLayout。我所看到的是,片段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();
1个回答

3
android:transitionGroup="true"应用于FragmentB的根布局。
ViewGroup#setTransitionGroup(boolean)的文档中:
更改此ViewGroup在Activity转换期间是否应被视为单个实体。如果为false,则ViewGroup不会进行过渡,只有其子元素。如果为true,则整个ViewGroup将一起过渡。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接