现在,当我使用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" />
为什么会发生这种情况我不知道
答案 0 :(得分:1)
我看不到用于调用动画的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);
答案 1 :(得分:0)
我可能错了,但我认为fade_out是一个实际的动画,而不是插补器。插补器具有_interpolator结尾。就像accele_interpolator,expectedate_interpolator等一样。所以应用程序崩溃是因为你传递了一个动画类而不是一个合适的插值器。