Activity animation slide from bottom

activity animation bottom to top
android activity transition animation library
android-activity transition slide up
start activity with animation android
android activity transition fade
finish activity with animation android
slide up animation android
setsharedelemententertransition activity

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!!

Make activity animate from top to bottom, You need to define your "slide up" animations from the linked question, and some new "slide down" animations that reverse the process. Open a Fragment with an Animation + Communicate with Activity - Android Studio Tutorial - Duration: 14:37. Coding in Flow 56,211 views

activity_slide_from_bottom.xml

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

activity_slide_to_bottom.xml

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

activity_stay.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 NewActivity:

startActivity(NewActivity.getIntent(this));
overridePendingTransition(R.anim.activity_slide_from_bottom, R.anim.activity_stay)

NewActivity finish():

@Override
public void onBackPressed() {
    super.onBackPressed();
    overridePendingTransition(R.anim.activity_stay, R.anim.activity_slide_to_bottom);
}

Also, the animation can be declared in styles

<style name="Animation.MyCustomAnimation" parent="android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/activity_slide_from_bottom</item>
    <item name="android:activityOpenExitAnimation">@anim/activity_stay</item>
    <item name="android:activityCloseEnterAnimation">@anim/activity_stay</item>
    <item name="android:activityCloseExitAnimation">@anim/activity_slide_to_bottom</item>
</style>

Set this style in theme:

<style name="Theme.MyAnimTheme" parent="YourThemeParent">
    <item name="android:windowAnimationStyle">@style/Animation.MyCustomAnimation</item>
</style>

Set the theme to your activity in manifest

<activity
    android:name=".NewActivity"
    android:theme="@style/Theme.MyCustomTheme" />

android:activityOpenEnterAnimation

When opening a new activity, this is the animation that is run on the next activity (which is entering the screen)

android:activityOpenExitAnimation

When opening a new activity, this is the animation that is run on the previous activity (which is exiting the screen).

android:activityCloseEnterAnimation

When closing the current activity, this is the animation that is run on the next activity (which is entering the screen).

android:activityCloseExitAnimation

When closing the current activity, this is the animation that is run on the current activity (which is exiting the screen).

android:windowReenterTransition

Reference to a Transition XML resource defining the desired Transition used to move Views in to the scene when returning from a previously-started Activity. Corresponds to Window.setReenterTransition(android.transition.Transition).

android:windowReturnTransition Reference to a Transition XML resource defining the desired Transition used to >move Views out of the scene when the Window is preparing to close. Corresponds to Window.setReturnTransition(android.transition.Transition).

Reference: https://developer.android.com/reference/android/R.attr

Start an activity using an animation, New activity slide from left to right, right to left, up to bottom or bottom to up. For making this, we must use overridePendingTransition(int enterAnim  Android Slide Up / Down Animations with Examples. In android, Slide Up and Slide Down animations are used to change the appearance and behaviour of the objects over a particular interval of time. The Slide Up and Slide Down animations will provide a better look and feel for our applications.

According to the documentation:

public void overridePendingTransition (int enterAnim, int exitAnim) Call immediately after one of the flavors of startActivity(Intent) or finish() to specify an explicit transition animation to perform next.

As of Build.VERSION_CODES.JELLY_BEAN an alternative to using this with starting activities is to supply the desired animation information through an ActivityOptions bundle to startActivity(Intent, Bundle) or a related function. This allows you to specify a custom animation even when starting an activity from outside the context of the current top activity.

That implies Just adding overridePendingTransition(R.anim.activity_stay, R.anim.activity_slide_to_bottom) after startActivity(Intent, Bundle) Should give the needed result.

Edit:

android:activityOpenEnterAnimation android:activityOpenExitAnimation android:activityCloseEnterAnimation android:activityCloseExitAnimation

Effects the activity

android:windowEnterTransition android:windowExitAnimation android:windowReenterTransition android:windowReturnTransition

Effects the window

For more info about activity vs window:

An Activity has a window (in which it draws its user interface),

a Window has a single Surface and a single view hierarchy attached to it,

a Surface include ViewGroup which holds views.

Source: What is an Android window?

In conclusion, You can use them for achieving the same result but they are different.

Open/Close Activity by slide animation, put your `setAnimation()`method before `setContentView()` method otherwise the animation will not work. So your AllCastActivity.java should look like this. Android Layout Animations from bottom to top and top to bottom on ImageView click. slide_in_bottom.xml : How to open activity from bottom to top in android. 2.

I think the Animations API is more preferrable to the Transitions API for what you are trying to accomplish. Here is a detailed explanation : https://www.reddit.com/r/androiddev/comments/8wqjzv/difference_between_animation_and_transitions_api/

Slide Animation Between Activites - Android Studio Tutorial, called activity we just do the opposite basically the screen drops from the top to the bottom. Also in this example we have the animation resources for sliding  Following on the answer by @schwiz, here is an animation override for the built-in Dialog theme, where I have defined local slide_up and slide_down animations. My activity specifies the theme MyDialog in order to have these transitions in and out.

Best way is to use styles, because you don't have to code in every Activity in case if you want this animation in all your activities.

Shortest way that i use always

To set slide theme in all your activities

<application
    android:theme="@style/Theme.SlideAnimWindow"
    ...
    >

To set slide theme in one activity

<activity
    android:name=".YourActivity"
    android:theme="@style/Theme.SlideAnimWindow" />

Put slide_from_bottom.xml in your res>anim.

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

Put slide_to_bottom.xml in your res>anim.

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

Put none.xml in your res>anim.

<?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" />

Put this style in res>values>styles.xml

<style name="SlideAnimation" parent="android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/slide_from_bottom</item>
    <item name="android:activityOpenExitAnimation">@anim/none</item>
    <item name="android:activityCloseEnterAnimation">@anim/none</item>
    <item name="android:activityCloseExitAnimation">@anim/slide_to_bottom</item>
</style>

<style name="Theme.SlideAnimWindow" parent="AppTheme">
    <item name="android:windowAnimationStyle">@style/SlideAnimation</item>
</style>

You can change android:duration="@android:integer/config_longAnimTime" duration according to your need. Now you are good to go.

Start your Activity with Slide Animation - Rohit Singh, BUT! The motion (transition) is NOT provided by… Here is the today topic — Activity Transition. There are some <slide android:slideEdge="bottom"> </slide​> In the same statement in which you execute finish (), execute your animation there too. Then, in the new activity, run another animation. In your new Activity-class you create a similiar method like the runFadeAnimation I wrote and then you run it in onCreate and don't forget to change the resources id to fadeout.

Android animation while switching activities, Today I'll be demonstrating how to add some basic left and right sliding animations to your Views and Activities on Android. First, here's a look  Android Slide / Walkthrough / Onboarding Screen Design Android Login Screen Design Using Bottom Sheet - Duration: #5.5 Android Explode Animation Activity Transition.

[Android] Material Design, In android slide up and slide down animations are useful to change the animation effect to the objects in our android application, we need to follow below steps. activity file MainActivity.java from \java\com.tutlane.slideupdownexample path  In this video we will learn, how to open a Fragment with an animation and how to communicate between the Fragment and it's Activity, using an Interface. We will send a String to the Fragment using

Animating Android Activities and Views with Left and Right Slide , Xamarin Android Tutorial - Activity Transition EDMT Dev. android 'xamarin' change activity, android transition animation, slide transition android studio, xamarin activity animation, xamarin

Comments
  • try using same duration for stay @android:integer/config_longAnimTime
  • @JyotiJK Thanks for answer, i tried it but it didn't help.
  • this link show why you should choose the right cycle for transition animation stackoverflow.com/a/23752530/9287163
  • If you want the transition work for whole application you can create a rootacivity and inherit it in the activity you need. see example stackoverflow.com/a/20188089/9287163
  • If you want to go with your method only try to overide you finish method and add a condition of is finishing to check and pass your overidependingtranstion() method there i hardly think that might work but you can try
  • What is the difference between android:activityOpenEnterAnimation android:activityOpenExitAnimation android:activityCloseEnterAnimation android:activityCloseExitAnimation and android:windowEnterTransition android:windowExitAnimation android:windowReenterTransition android:windowReturnTransition When should you use one instead of the other?
  • What is the difference between android:activityOpenEnterAnimation android:activityOpenExitAnimation android:activityCloseEnterAnimation android:activityCloseExitAnimation and android:windowEnterTransition android:windowExitAnimation android:windowReenterTransition android:windowReturnTransition When should you use one instead of the other?
  • What is the difference between android:activityOpenEnterAnimation android:activityOpenExitAnimation android:activityCloseEnterAnimation android:activityCloseExitAnimation and android:windowEnterTransition android:windowExitAnimation android:windowReenterTransition android:windowReturnTransition When should you use one instead of the other?