Thursday, 30 March 2017

Animation activity transition in android



STEP 1 : Create anim folder under res folder




STEP 2 : Create fade_in.xml under anim folder

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

STEP 3 : Create fade_out.xml under anim folder

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

STEP 4 : Write the below code when you change from one activity to another

startActivity(new Intent(getApplicationContext(),YourActivity.class));
overridePendingTransition(R.anim.fade_in,R.anim.fade_out);

No comments:

Post a Comment