Display Activity From Bottom to Top

AndroidAnimationAndroid ActivityAndroid Intent

Android Problem Overview


I want to display one activity to another from bottom to top animation using Intent.

Given me some example for that like below

Intent i2 = new Intent(main.this, test.class);
startActivity(i2);

with animation bottom to top.

Android Solutions


Solution 1 - Android

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 );

There an introduction to Android animation here which may help you further.

Solution 2 - Android

As i googled sliding up transition and landed here but Mark answer is incomplete without transition involved on coming back to the same activity.

Overide finish in activity

@Override
public void finish() {
    super.finish();
    overridePendingTransition(R.anim.slide_from_top,R.anim.slide_in_top);
}

finish()

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                finishAfterTransition();
            }else finish();

slide_from_top.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="-100%p" android:toYDelta="0%p"
android:duration="@android:integer/config_shortAnimTime"/>

slide_in_top.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="100%p"
android:duration="@android:integer/config_shortAnimTime"/>

Solution 3 - Android

First : animate the layout of your activity 1 ,, Second : at the end of this aniamtion , Start your second Activity , and animate her Content Layout

Use TranslateAnimation(int fromX,int toX, int fromY , int toY) ;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNikhilView Question on Stackoverflow
Solution 1 - AndroidMark AllisonView Answer on Stackoverflow
Solution 2 - AndroidAklesh SinghView Answer on Stackoverflow
Solution 3 - AndroidHoucineView Answer on Stackoverflow