片段的交易自定义动画 - 机器人 [英] Fragment transaction custom animation - Android
问题描述
我试图做的事:
ft.setCustomAnimations(android.R.animator.fade_in,android.R.animator.fade_out);
不过,我得到一个例外,未知的动画名称:objectAnimator - 详情如下:
But I am getting an exception with Unknown animation name: objectAnimator - see details below:
04-08 10:45:41.637: ERROR/AndroidRuntime(1222): FATAL EXCEPTION: main
04-08 10:45:41.637: ERROR/AndroidRuntime(1222): java.lang.RuntimeException: Unknown animation name: objectAnimator
04-08 10:45:41.637: ERROR/AndroidRuntime(1222): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:124)
04-08 10:45:41.637: ERROR/AndroidRuntime(1222): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:91)
04-08 10:45:41.637: ERROR/AndroidRuntime(1222): at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:72)
为什么会出现错误?我不知道如何解决它。请帮忙。谢谢你。
Why is there an error? I am not sure how to solve it. Please Help. Thanks.
FYI:我的分SDK是7,但我搭建SDK 11兼容性库
FYI: My min sdk is 7, but I am build for sdk 11 with compatibility library.
推荐答案
您必须对目标3.0(API等级11),以使用新的对象动画。如果您正在为低版本,您必须使用较旧的动画过渡(android.R.anim)。
You have to target 3.0 (API level 11) to use the new object animator. If you are building for lower versions you must use the older anim transitions (android.R.anim).
不过,我认为,片段动画在compat的图书馆由戴安娜Hackborn在<一个是规定被打破href="http://groups.google.com/group/android-developers/browse_thread/thread/5ef5ba1be9f40c56/a846578d91a032c0?hide_quotes=no">this帖子。
However, I think that fragment animations in the compat library are broken as stated by Dianne Hackborn in this post.
这篇关于片段的交易自定义动画 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!