fade_out,插值器使应用程序崩溃
现在,当我使用 Linear_interpolator 代替淡出时,应用程序和我的动画效果完美,但是当我使用淡出时,它使我的应用程序强制关闭
,我的 LogCat 错误是
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): FATAL EXCEPTION: main
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): java.lang.RuntimeException: Unknown interpolator name: alpha
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createInterpolatorFromXml(AnimationUtils.java:312)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.loadInterpolator(AnimationUtils.java:255)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.Animation.setInterpolator(Animation.java:328)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.Animation.<init>(Animation.java:218)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AlphaAnimation.<init>(AlphaAnimation.java:40)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:108)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:106)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:83)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:64)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.View.dispatchTouchEvent(View.java:3762)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.os.Looper.loop(Looper.java:123)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at java.lang.reflect.Method.invoke(Method.java:521)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at dalvik.system.NativeStart.main(Native Method)
我的 xml 代码是
<alpha
android:interpolator="@android:anim/linear_interpolator"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="1100"
android:duration="200"
android:zAdjustment="normal" />
为什么会发生这种情况我不知道
Now when I use linear_interpolator insted of fade-out the app and my animation works perfectly but when I use fade-out it makes my app FORCE-CLOSE
And my LogCat errors are
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): FATAL EXCEPTION: main
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): java.lang.RuntimeException: Unknown interpolator name: alpha
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createInterpolatorFromXml(AnimationUtils.java:312)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.loadInterpolator(AnimationUtils.java:255)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.Animation.setInterpolator(Animation.java:328)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.Animation.<init>(Animation.java:218)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AlphaAnimation.<init>(AlphaAnimation.java:40)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:108)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:106)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:83)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:64)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.View.dispatchTouchEvent(View.java:3762)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.os.Looper.loop(Looper.java:123)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at java.lang.reflect.Method.invoke(Method.java:521)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-20 03:35:02.988: ERROR/AndroidRuntime(2596): at dalvik.system.NativeStart.main(Native Method)
My xml code is
<alpha
android:interpolator="@android:anim/linear_interpolator"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="1100"
android:duration="200"
android:zAdjustment="normal" />
Why this is happening I am not getting any idea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看不到你调用动画的Java代码?但尝试一下
fade_in.xml
fade_out.xml
并从代码中调用
I can not see your Java code for calling animation? but try this
fade_in.xml
fade_out.xml
and call from code
我可能是错的,但我认为 fade_out 是一个实际的动画,而不是插值器。据我所知,插值器有 _interpolator 结尾。像accelerate_interpolator、expect_interpolator等。因此应用程序崩溃是因为您传递了动画类而不是正确的插值器。
I may be wrong, but I think fade_out is an actual animation, not an interpolator. Interpolators have _interpolator endings afaik. Like accelerate_interpolator, anticipate_interpolator, etc. So the app crashes because you passed an animation class instead of a proper interpolator.