Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Activities animations not working

I have not been able to understand why my custom animations are not overriding the system animations when i switch between activities in my app.

styles.xml

<style name="AppBaseTheme" parent="android:Theme.Holo.Light"></style>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:buttonStyle">@style/buttonStyle</item>
    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    <item name="android:editTextStyle">@style/editTextStyle</item>
    <item name="android:windowAnimationStyle">@style/ActivityAnimationStyle</item>
</style>

<!-- activities animation style start -->
<style name="ActivityAnimationStyle" parent="@android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/fadein</item>
    <item name="android:activityOpenExitAnimation">@anim/fadeout</item>
    <item name="android:activityCloseEnterAnimation">@anim/fadein</item>
    <item name="android:activityCloseExitAnimation">@anim/fadeout</item>
</style>
<!-- activities animation style end -->

fadein.xml:

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/anticipate_interpolator"
    android:toAlpha="1.0" />

fadeout.xml

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromAlpha="1.0"
    android:interpolator="@android:anim/anticipate_interpolator"
    android:toAlpha="0.0" />

Manifest:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

With these all set, I was hoping to see fading animations but this is not happening at all.

FYI, I noticed if I use android:windowEnterAnimation and android:windowExitAnimation instead and increase value of android:duration to something like 2000 in animations files then I do see very slow fading animations but I want have animations in all four cases and faster fading.

I am using Kitkat 4.4.2. Thanks for your help

like image 868
Dev01 Avatar asked Dec 22 '14 07:12

Dev01


1 Answers

This usually happened at Android 4.4.2. Try this

http://blog.csdn.net/xuewater/article/details/36398803

like image 72
yeling Avatar answered Sep 28 '22 04:09

yeling