2016-03-24 170 views
1

發生衝突我已經在我的style.xml以下的風格,是一個跟進我的問題在這裏Activity transition effects: slide in for the top activity and scale for the bottom activity設置樣式的android:windowIsTranslucent似乎與windowAnimationStyle

<style name="RevealTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:windowIsTranslucent">true</item> 
    <item name="android:windowAnimationStyle">@style/ActivityAnimation</item> 
</style> 

<style name="ActivityAnimation" parent="@android:style/Animation"> 
    <item name="android:activityOpenEnterAnimation">@anim/animation_in</item> 
    <item name="android:activityOpenExitAnimation">@anim/animation_out</item> 
    <item name="android:activityCloseEnterAnimation">@anim/animation_back_in</item> 
    <item name="android:activityCloseExitAnimation">@anim/animation_back_out</item> 
</style> 

我發現,風格android:windowBackground衝突與android:windowAnimationStyle並且動畫沒有完全顯示。如果我包括上述風格是我style.xml和運行我的應用程序,我得到如下:

enter image description here

如果我在這裏行註釋掉:

<style name="RevealTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <!--<item name="android:windowIsTranslucent">true</item> COMMENTED OUT--> 
    <item name="android:windowAnimationStyle">@style/ActivityAnimation</item> 
</style> 

<style name="ActivityAnimation" parent="@android:style/Animation"> 
    <item name="android:activityOpenEnterAnimation">@anim/animation_in</item> 
    <item name="android:activityOpenExitAnimation">@anim/animation_out</item> 
    <item name="android:activityCloseEnterAnimation">@anim/animation_back_in</item> 
    <item name="android:activityCloseExitAnimation">@anim/animation_back_out</item> 
</style> 

enter image description here

我不明白爲什麼會出現這種情況。我需要windowIsTranslucent來處理其他一些動畫。

這是我使用(感謝尼古拉·多羅寧)的XML動畫類:

activity_in.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <translate 
     android:fromXDelta="100%p" 
     android:toXDelta="0%p" 
     android:duration="@integer/activityAnimationTime"> 
    </translate> 
</set> 

activity_out.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <scale 
     android:fromXScale="1.0" 
     android:toXScale="0.84" 
     android:fromYScale="1.0" 
     android:toYScale="0.84" 
     android:duration="@integer/activityAnimationTime"/> 
    <translate 
     android:fromYDelta="0%" 
     android:fromXDelta="0%" 
     android:toYDelta="8%" 
     android:toXDelta="16%" 
     android:duration="@integer/activityAnimationTime"/> 

    <alpha 
     android:fromAlpha="1.0" 
     android:toAlpha="0.25" 
     android:duration="@integer/activityAnimationTime"/> 

</set> 

activity_back_in.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <scale 
     android:fromXScale="0.84" 
     android:toXScale="1.0" 
     android:fromYScale="0.84" 
     android:toYScale="1.0" 
     android:duration="@integer/activityAnimationTime"/> 
    <translate 
     android:fromYDelta="8%" 
     android:fromXDelta="16%" 
     android:toYDelta="0%" 
     android:toXDelta="0%" 
     android:duration="@integer/activityAnimationTime"/> 

    <alpha 
     android:fromAlpha="0.25" 
     android:toAlpha="1.0" 
     android:duration="@integer/activityAnimationTime"/> 

</set> 

activity_back_out.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <translate 
     android:fromXDelta="0%p" 
     android:toXDelta="100%p" 
     android:duration="@integer/activityAnimationTime"> 
    </translate> 
</set> 

回答

0

你可以試試這個,改變

<style name="ActivityAnimation" parent="@android:style/Animation"> 

<style name="ActivityAnimation" parent="@android:style/Animation.Translucent">