6

Can anybody tell how to transition the activity from top to bottom in Android, perhaps with an example?

Rasoul Miri
  • 11,234
  • 1
  • 68
  • 78
VaaS
  • 637
  • 2
  • 12
  • 18

1 Answers1

16

Define an animation in res/anim/slide_in_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="100%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

and another at res/anim/slide_out_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime"/>

Then apply these after to call startActivity:

Intent i2 = new Intent(main.this, test.class);
startActivity(i2);
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
Luismi
  • 1,071
  • 1
  • 13
  • 18
  • 1
    this answer with some explanation would be great. Only code is not what people look for. If their would be some explanation we (beginners) would get something rich. – Shubham AgaRwal Nov 21 '15 at 15:14