android - fragment 动画 : difference between setCustomAnimations and setTransitionStyle

标签 android android-fragments android-animation

我想为两个 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/

相关文章:

Android 如何知道你的标签何时获得焦点,

android - setOnClickListener 未在 fragment 中调用

java - fragment 无法转换为上下文

Android - 沿 Y 轴旋转对象

android - 具有多个 View 同步问题的滑动动画

android - 为什么 float 提示动画不起作用?

android - CardView 工具栏

android - BroadcastReceiver 所需的帮助

android emulator error permission error for write to sdcard 错误

php - Android eclipse 注册页面应用已停止错误