活动转换从左到右滑动并向右移动动画

时间:2016-06-16 15:18:38

标签: android

在我的Activity过渡幻灯片中,幻灯片输入/输出动画从左到右从右向后移动,例如当前动画就像这张图片一样:

enter image description here

但是我想在从左到右打开活动后,从右边出来,不是从左到左,就像这张图片一样:

enter image description here

遗憾的是,我无法在onBackPressed()

上更改我的xml动画

ActivityMain:

Intent i = new Intent(ActivityMain.this, ActivityRobotAssistant.class);
startActivity(i);
overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right);

ActivitySecond:

public void onBackPressed() {
    super.onBackPressed();
    overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
}

pull_in_left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="-100%"
    android:toXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
     />

pull_in_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="100%"
    android:toXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
     />

push_out_left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toXDelta="-100%" />

push_out_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toXDelta="100%" />

0 个答案:

没有答案