gpt4 book ai didi

android - 同时制作 fragment 过渡动画 View

转载 作者:太空宇宙 更新时间:2023-11-03 13:43:17 25 4
gpt4 key购买 nike

我正在用 fragment B 替换 fragment A 并为其设置动画。 fragment B 有一个 RelativeLayout 和一个 TextView 和一个 ListView。我可以看到 fragment B 中的 View 是单独动画的,TextView 以不同于列表项 1 副标题的速度滑入,而列表项 1 标题和图标立即出现而没有动画,我希望整个 View 同时具有动画效果,这有可能实现吗?

    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();

最佳答案

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

来自 docs of ViewGroup#setTransitionGroup(boolean) :

Changes whether or not this ViewGroup should be treated as a single entity during Activity Transitions. If false, the ViewGroup won't transition, only its children. If true, the entire ViewGroup will transition together.

关于android - 同时制作 fragment 过渡动画 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47270668/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com