Fragment animation : difference between setCustomAnimations and setTransitionStyle

不羁的心 提交于 2019-12-20 18:46:28

问题


I'd like to animate the transition between two fragments which is performed thanks to FragmentTransaction.replace(). I'd like to specify my custom animation in a XML file.

What is the difference between calling FragmentTransaction.setCustomAnimations() and FragmentTransaction.setTransitionStyle() ?

Thanks.


回答1:


setCustomAnimations(int, int, int, int) allows you to specify your animation resources directly. If you use setTransitionStyle(int), on the other hand, you'll have to specify them by using a FragmentAnimation style and setTransition(int).

It is worth mentioning that the compatibility library ignores setTransitionStyle(int), so if you are using it you have to use setCustomAnimations(int, int, int, int) for sure.

For more info on this, check out this excellent post about Fragment states and Fragment animations



来源:https://stackoverflow.com/questions/10972540/fragment-animation-difference-between-setcustomanimations-and-settransitionsty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!