Search code examples
androidanimationuiviewanimationtransition

"Chase" current view off screen with "Next" view in android (overridePendingTransition)


My current android application has a requirement to have the "Next" screen slide up from the bottom of the screen as the current view slides out from the top. I can achieve this effect with anim and overridePendingTransition. However i want the "Next" screen to slide up faster from the bottom than than the current screen is sliding out the top of the screen. What attributes (and values) do i require in my animation xml files to achieve this effect?


Solution

  • This will slide the next screen in from the bottom to the top and the current screen out from the top and 25% up making the next screen slide over the current screen.

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