片段动画:setCustomAnimations 和 setTransitionStyle 之间的区别

2024-01-05

我想对两个片段之间的过渡进行动画处理,这要归功于FragmentTransaction.replace()。我想在 XML 文件中指定我的自定义动画。

调用有什么区别FragmentTransaction.setCustomAnimations() and FragmentTransaction.setTransitionStyle() ?

Thanks.


setCustomAnimations(int, int, int, int) https://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations%28int,%20int,%20int,%20int%29允许您直接指定动画资源。如果你使用setTransitionStyle(int) https://developer.android.com/reference/android/app/FragmentTransaction.html#setTransitionStyle%28int%29,另一方面,您必须使用Fragment动画风格 https://developer.android.com/reference/android/R.styleable.html#FragmentAnimation and setTransition(int) https://developer.android.com/reference/android/app/FragmentTransaction.html#setTransition%28int%29.

值得一提的是兼容性库忽略 setTransitionStyle(int) https://developer.android.com/reference/android/app/FragmentTransaction.html#setTransitionStyle%28int%29,所以如果你正在使用它,你必须使用setCustomAnimations(int, int, int, int) https://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations%28int,%20int,%20int,%20int%29一定。

有关这方面的更多信息,请查看此关于片段状态和片段动画的优秀文章 http://daniel-codes.blogspot.com/2012/06/fragment-transactions-reference.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

片段动画:setCustomAnimations 和 setTransitionStyle 之间的区别 的相关文章

随机推荐