What I use:
activity_stay.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0%p"
android:toYDelta="0%p" />
</set>
activity_slide_to_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0"
android:toYDelta="100%p" />
</set>
activity_slide_from_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="100%p"
android:toYDelta="0" />
</set>
Start NewActivity:
startActivity(NewActivity.getIntent(this))
overridePendingTransition(R.anim.activity_slide_from_bottom, R.anim.activity_stay)
NewActivity finish():
finish()
overridePendingTransition(R.anim.activity_stay, R.anim.activity_slide_to_bottom)
When NewActivity is started OldActivity disappear - I see blank white screen above which NewActivity slide to top. However what I need is my NewActivity sliding to top above the OldActivity content when started. How can I achieve this?
UPD: when I finish my NewActivity for some reasons all animations execute perfectly: NewActivity slide to bottom with OldActivity content appearing below NewActivity content.
You can achieve animations using below code :
bottom_up.xml :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="90%"
android:toYDelta="0" />
</set>
bottom_down.xml :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1500"
android:fromYDelta="5"
android:toYDelta="90%" />
</set>
nothing.xml :
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromYDelta="0%p"
android:toYDelta="0%p" />
Start Second Activity :
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.bottom_up, R.anim.nothing);
On finish of second activity :
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.nothing, R.anim.bottom_down);
}
Docs.:
Start an activity using an animation Activity transitions in material design apps provide visual connections between different states through motion and transformations between common elements. You can specify custom animations for enter and exit transitions and for transitions of shared elements between activities.
An enter transition determines how views in an activity enter the scene. For example, in the explode enter transition, the views enter the scene from the outside and fly in towards the center of the screen. An exit transition determines how views in an activity exit the scene. For example, in the explode exit transition, the views exit the scene away from the center.
Specify custom transitions First, enable window content transitions with the android:windowActivityTransitions attribute when you define a style that inherits from the material theme. You can also specify enter, exit, and shared element transitions in your style definition:
<style name="BaseAppTheme" parent="android:Theme.Material"> <!-- enable window content transitions -->
<item name="android:windowActivityTransitions">true</item>
<!-- specify enter and exit transitions -->
<item name="android:windowEnterTransition">@transition/explode</item>
<item name="android:windowExitTransition">@transition/explode</item> </style>
Please check doc. here
Enjoy!!