I want to achieve a sliding effect from left to right when I move from one activity to another. For that I am using the following code, but I am not getting any results. Please correct me.
In java both files:
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
setContentView(R.layout.main);
Two files in res/anim directory:
fadein.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/slide_out_right"
android:toAlpha="1.0" >
</alpha>
fadeout.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/slide_in_left"
android:toAlpha="1.0" >
</alpha>
Add this two file in res/anim folder.
R.anim.slide_out_bottom
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@integer/time_duration_max"
android:fromXDelta="0%"
android:fromYDelta="100%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
R.anim.slide_in_bottom
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@integer/time_duration_max"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="100%" />
</set>
And write the below line of code in your view click listener.
startActivity(new Intent(MainActivity.this, NameOfTargetActivity.class));
overridePendingTransition(R.anim.slide_out_bottom, R.anim.slide_in_bottom);