fade_out ,interpolator crash the app
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(M开发者_StackOverflow中文版ethod.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
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);
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.
精彩评论