7

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

Dev01
  • 4,082
  • 5
  • 29
  • 45
  • did you were given a solution please? I'm exactly confronted to this problem! I already created 2 topics about it, having no answer... https://stackoverflow.com/questions/52234457/how-to-fade-out-an-activitys-ui-and-fade-in-another-activitys-ui + https://stackoverflow.com/questions/52237312/why-the-xml-specified-transition-isnt-executed-or-why-its-specified-duration – JarsOfJam-Scheduler Sep 08 '18 at 20:18

2 Answers2

3

This usually happened at Android 4.4.2. Try this

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

yeling
  • 152
  • 2
  • 6
-1

As far as i remember, if you want to use the trasitions defined in themes you have to change activities using

startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());

Chris K.
  • 977
  • 8
  • 18
  • I don't want to do this repeating work before starting activiteis, this is why I have used styles so all activities get same style without having to write java code. – Dev01 Dec 22 '14 at 07:52
  • Even if you use styles you have to write this piece of code every time, this is still less work then specifing OverridePendingTransitions with specific animations, because it takes the animation from your XML files – Chris K. Dec 22 '14 at 07:55
  • 1
    This only applies to activity __Transitions__ (introduced in Android 5.0), not activity __Animations__ – Alex Semeniuk Jan 15 '19 at 10:49