A -> B 的转场动画:
A:
ARouter.getInstance().build(ArouterPath.PATH_AUDIO_PLAYER)
.withSerializable("AudioPlayerListData", audioPlayerListBean as Serializable)
.withTransition(R.anim.public_translate_bottom_in,0)//入场动画,大家都知道放到build后面
.navigation(this@MainActivity)//这里传入当前activity
B:
@Override
public void finish() {
super.finish();
overridePendingTransition(0, R.anim.public_translate_bottom_out);//出场动画
}
动画:
in:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200">
<translate
android:fromYDelta="100%p"
android:toYDelta="0"
/>
</set>
out:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200">
<translate
android:fromYDelta="0%p"
android:toYDelta="100%p"
/>
</set>
还有个小问题可以优化下,入场动画时有个一闪而过的黑屏。
解决方案:给B一个透明的主题
<style name="TransparentTheme" parent="public_AppTheme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>