4
我希望达到下面显示的效果。效果来自Facebook。活动过渡效果:滑入顶部活动并缩放底部活动
我在活动尝试这样一个:
overridePendingTransition(R.anim.anim_left_to_right, R.anim.scale_out);
而且在活动B:
overridePendingTransition(R.anim.anim_right_to_left, R.anim.scale_in);
凡XML显示如下:
R.anim.anim_left_to_right
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="100%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="0%"
android:duration="300"/>
</set>
R.anim.anim_right_to_left
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
</set>
R.anim.scale_out
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="1.0"
android:toYScale="1.0"
android:duration="500"
android:fillBefore="false" />
</set>
R.anim.scale_in
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="0.8"
android:toYScale="0.8"
android:duration="500"
android:fillBefore="false" />
</set>
但是,它没有达到预期的效果 - 出于某种原因,我可能无法正确理解。任何人都可以帮助我吗?
感谢尼古拉。它实际上是工作 - 我只是把你的类放到一个测试应用程序,它似乎工作正常。关于这个问题的后续主题,我还有一个问题,你可以帮我一下吗? http://stackoverflow.com/questions/36207321/setting-style-androidwindowistranslucent-seems-to-conflict-with-windowanimation – Simon
我不确定是否有可能获得这种动画与半透明的活动,因为如果你设置“ windowIsTranslucent“为true,您只能提供”windowEnterAnimation“和”windowExitAnimation“。请看看https://gist.github.com/lassana/136cd637dafe872cc0f3 –