Skip to content Skip to sidebar Skip to footer

Why My Close Activity Animation Doesn't Work On Android 4.0 (ics)

I made a theme with a custom animation (slide up and slide down). The animation works fine on the older android versions.. However, when I try it out on Android 4.0 (ICS) the on c

Solution 1:

Specifying animations from the manifest appears to be broken in ICS :-( The override animation solution works fine, but you probably don't want to hard-code the animations. It would be nice to get them from the manifest as you would for other versions of the platform.. so....

add a couple of member fields to your activity to hold the ids of the animations attached to your activity..

protectedint activityCloseEnterAnimation;
protectedint activityCloseExitAnimation;

and somewhere in your onCreate...

// Retrieve the animations set in the theme applied to this activity in the// manifest..
TypedArray activityStyle = getTheme().obtainStyledAttributes(newint[] {android.R.attr.windowAnimationStyle});
int windowAnimationStyleResId = activityStyle.getResourceId(0, 0);      
activityStyle.recycle();

// Now retrieve the resource ids of the actual animations used in the animation style pointed to by // the window animation resource id.
activityStyle = getTheme().obtainStyledAttributes(windowAnimationStyleResId, newint[] {android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation});
activityCloseEnterAnimation = activityStyle.getResourceId(0, 0);
activityCloseExitAnimation = activityStyle.getResourceId(1, 0);
activityStyle.recycle();

then wherever your activity finishes/should apply animation include...

overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);

and your activities should correctly honour the animations you set in the theme/style attached to activities in your manifest.

Solution 2:

I have also tried but its not working here. Don't know what is the problem but this.overridePendingTransition(R.anim.no_anim,R.anim.push_down_out_no_alpha); this code is working fine

Post a Comment for "Why My Close Activity Animation Doesn't Work On Android 4.0 (ics)"