You can override the transition between actions that perform the following actions:
Button btn = (Button)findViewById(R.id.myBtn); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(ActualActivity.this, TargetActivity.class)); overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); } });
Where slide_in_up and slide_out_up are your custom animations saved in res / anim. Here are some sample code:
slide_in_up:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="300"/> </set>
slide_out_up:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="300"/> </set>
This example will move your activity from top to bottom. You can change the animation files to get different animations.
source share