Activity切换动画无效(android:windowIsTranslucent)影响(android:windowAnimationStyle)

最近写项目的时候需要用到大量的activity切换动画,于是就用了考虑到了theme中引用style来实现,但是竟然无效,很是郁闷,几经波折,找到了原因,原来是style里面设置了android:windowIsTranslucent这个属性,代码如下:

<style name="AppTranslateTheme" parent="AppBaseTheme">

        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowAnimationStyle">@style/animation_translucent_translate</item>
       
    </style>

解决办法就是,windowAnimationStyle需要继承Animation.Translucent,一般情况是继承的Animation.Activity,下面是代码:

<!--  <style name="anim_activity" parent="@android:style/Animation.Activity">
        <item name="android:activityOpenEnterAnimation">@anim/activity_open_in_anim</item>
        <item name="android:activityOpenExitAnimation">@anim/activity_open_out_anim</item>
        <item name="android:activityCloseEnterAnimation">@anim/activity_close_in_anim</item>
        <item name="android:activityCloseExitAnimation">@anim/activity_close_out_anim</item>
    </style> -->
    <style name="animation_translucent_translate" parent="@android:style/Animation.Translucent">  
        <item name="android:windowEnterAnimation">@anim/activity_open_in_anim</item>  
        <item name="android:windowExitAnimation">@anim/activity_open_out_anim</item>  
    </style>

问题解决。

你可能感兴趣的:(Activity切换动画无效(android:windowIsTranslucent)影响(android:windowAnimationStyle))