简体   繁体   中英

How to Implement activity transition animation in Android Studios

How can we use transition animations between 2 activities in android studios.We would be normally using a button and when clicked opens a new activity using an intent.Now how can we use transition animations between this two activities adding to the fact that i am very beginner in android studios and i please expect the answer to be a bit more clear. Thank you.

res/anim/

activity_fade_in.xml :

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/accelerate_interpolator"
   android:fromAlpha="0.0" android:toAlpha="1.0"
   android:duration="500" />

activity_fade_out.xml:

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/accelerate_interpolator"
   android:fromAlpha="1.0" android:toAlpha="0.0"
   android:fillAfter="true"
   android:duration="500" />

In Activity or Fragment:

 startActivity(intent);
 overridePendingTransition(R.anim.activity_fade_in,R.anim.activity_fade_out);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM