slide up xml animation on change activity in android

白昼怎懂夜的黑 提交于 2019-12-03 06:01:17
Mansi

for slide_in xml :

<translate 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:duration="@android:integer/config_longAnimTime" 
      android:fromXDelta="-100%p" 
      android:toXDelta="0%p">
</translate>

for slide_out xml:

<translate
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:duration="@android:integer/config_longAnimTime" 
      android:fromXDelta="0" 
      android:toXDelta="100%p">
</translate>

Java code :

Intent intent = new Intent(this, newActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);

put both xml files in res/anim folder.

The accepted answer isn't what the question was asking, which is animations that slide up from the bottom and slide out from the top.

pull_up_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%"
android:toYDelta="0%" />

push_out_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%"
android:toYDelta="100%" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!