gpt4 book ai didi

android - 设置样式android :windowIsTranslucent seems to conflict with windowAnimationStyle

转载 作者:行者123 更新时间:2023-11-30 01:27:47 26 4
gpt4 key购买 nike

我在我的 style.xml 中使用了以下样式,这是对我的问题的跟进 Activity transition effects: slide in for the top activity and scale for the bottom activity :

<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 动画类(感谢 Nikolai Doronin):

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>

最佳答案

你可以试试这个,改

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

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

关于android - 设置样式android :windowIsTranslucent seems to conflict with windowAnimationStyle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36207321/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com