我想为两个 fragment 之间的过渡设置动画,这要归功于 FragmentTransaction.replace()
。我想在 XML 文件中指定我的自定义动画。
调用 FragmentTransaction.setCustomAnimations()
和 FragmentTransaction.setTransitionStyle()
有什么区别?
谢谢。
最佳答案
setCustomAnimations(int, int, int, int)
允许您直接指定动画资源。如果你使用 setTransitionStyle(int)
,另一方面,您必须使用 FragmentAnimation style 来指定它们和 setTransition(int)
.
值得一提的是兼容性库忽略 setTransitionStyle(int)
,所以如果你正在使用它,你必须使用 setCustomAnimations(int, int, int, int)
当然。
有关这方面的更多信息,请查看此 excellent post about Fragment states and Fragment animations
关于android - fragment 动画 : difference between setCustomAnimations and setTransitionStyle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10972540/