slide transition using overridePendingTransition

时间:2016-06-06 14:17:07

标签: android css

I am trying to make slide between two activities but it is not effective. do I need a special style? I am working on "Theme.AppCompat.Light.NoActionBar"

I tried "Fade in/out" transition and it is working. but the slide is not .. what is the problem?

res/anim/enter:

def Energy(coeffs, k):
    return np.sqrt(np.sum(np.array(coeffs[-k]) ** 2)) / len(coeffs[-k])

res/anim/leave:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="-100%" android:toXDelta="0%"
    android:duration="700"/>
</set>

New Activity:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
    android:fromXDelta="0%" android:toXDelta="100%"
    android:duration="700" />
</set>

Main Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.overridePendingTransition(R.anim.enter,
            R.anim.leave);
    setContentView(R.layout.activity_analyzer);
}

1 个答案:

答案 0 :(得分:1)

你应该将它放在之前的活动中,如下所示:

    // after startActivity(intent);
    overridePendingTransition(R.anim.enter,
            R.anim.leave);