使用overridePendingTransition方法,我如何将当前(已完成)活动设置为动画并将其移开,从而揭示其背后的新加载(startActivity)活动?
slide_out_bottom.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@anim/full_screen_modal_decelerate_interpolator">
<translate android:fromYDelta="0%" android:toYDelta="100%" android:fillAfter="true"
android:duration="300"/>
</set>
的onclick:
@Override
public void onClick(View v) {
finish();
Intent intent = new Intent(context, TestActivity.class);
startActivity(intent);
overridePendingTransition(0, R.anim.slide_out_bottom);
}
答案 0 :(得分:2)
使用zAdjustment
进行操作,以便退出活动位于顶部:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@anim/full_screen_modal_decelerate_interpolator"
android:zAdjustment="top">
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="300"/>
</set>