How to give top to bottom animation in Android?

Deadly 提交于 2019-11-28 21:24:18

Just Change -100 to 100 (remove minus) in slide_out_up.xml

@Override
public void onBackPressed() {
    finish();
    overridePendingTransition(R.anim.enter_anim, R.anim.exit_anim);
}

i just implemented it with two more xml files having like

slide up, 100 to 0 and 0 to -100

slide down -100 to 0 and 0 to 100

it works perfect.

Worked on my tablet 4.0.3.

slide_out_up.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:fromYDelta="0%p"
        android:toYDelta="-100%p" />

</set>

slide_in_up:xml:

<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:fromYDelta="-100%p"
        android:toYDelta="0%p" />

</set>

style.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="DialogAnimationOutUpInUp">
        <item name="android:windowEnterAnimation">@anim/slide_in_up</item>
        <item name="android:windowExitAnimation">@anim/slide_out_up</item>
    </style>

</resources>

You can override the back button press behavior and set the appropriate animation that you want, like this:

@Override
public void onBackPressed() {
    finish();
    overridePendingTransition(R.anim.enter_anim, R.anim.exit_anim);
}

Change the animations at the overridePendingTransition so that it fits the ones that you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!