fade_out,插值器使应用程序崩溃

发布于 2024-11-25 02:23:11 字数 4061 浏览 1 评论 0原文

现在,当我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧街凉风 2024-12-02 02:23:11

我看不到你调用动画的Java代码?但尝试一下

fade_in.xml

   <?xml version="1.0" encoding="utf-8"?>
       <alpha xmlns:android="http://schemas.android.com/apk/res/android"
          android:interpolator="@android:anim/decelerate_interpolator"
          android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />

fade_out.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="1000" />

并从代码中调用

startActivity(new Intent(ChangeLevelActivity.this, GameActivity.class));
overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);

I can not see your Java code for calling animation? but try this

fade_in.xml

   <?xml version="1.0" encoding="utf-8"?>
       <alpha xmlns:android="http://schemas.android.com/apk/res/android"
          android:interpolator="@android:anim/decelerate_interpolator"
          android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />

fade_out.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="1000" />

and call from code

startActivity(new Intent(ChangeLevelActivity.this, GameActivity.class));
overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
琴流音 2024-12-02 02:23:11

我可能是错的,但我认为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文