动画片段:setCustomAnimations和setTransitionStyle之间的区别 [英] Fragment animation : difference between setCustomAnimations and setTransitionStyle

查看:1555
本文介绍了动画片段:setCustomAnimations和setTransitionStyle之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这是执行的感谢 FragmentTransaction.replace两个片段之间的过渡动​​画效果()。我想指定一个XML文件我的自定义动画。

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.

调用 FragmentTransaction.setCustomAnimations() FragmentTransaction.setTransitionStyle()之间的区别是什么?

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

感谢。

推荐答案

<一个href="https://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations%28int,%20int,%20int,%20int%29"相对=nofollow> setCustomAnimations(INT,INT,INT,INT) ,您可以直接指定动画资源。如果你使用<一个href="https://developer.android.com/reference/android/app/FragmentTransaction.html#setTransitionStyle%28int%29"相对=nofollow> setTransitionStyle(INT) ,在另一方面,你必须使用的 FragmentAnimation风格和<一href="https://developer.android.com/reference/android/app/FragmentTransaction.html#setTransition%28int%29"相对=nofollow> setTransition(INT)

值得一提的是,兼容性库忽略 <一个href="https://developer.android.com/reference/android/app/FragmentTransaction.html#setTransitionStyle%28int%29"相对=nofollow> setTransitionStyle(INT) 的,所以如果你使用它,你必须使用<一个href="https://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations%28int,%20int,%20int,%20int%29"相对=nofollow> setCustomAnimations(INT,INT,INT,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

这篇关于动画片段:setCustomAnimations和setTransitionStyle之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆