10.7 C
New York
Tuesday, December 6, 2022

Fade in Fade out Animation Effect to Android App

How to Add Fade in Fade out Animation to Android App

This tutorial explains how to add fade in and fade out animation in Android Application.

Please follow the steps below in order to add fade in fade out animation to Android Application:

1.First add a new handler. It will open the application

And after 4 seconds open the second activity as the ‘welcome’ timeout = 4000.

2.Go to res > New > Directory.

3.Go to anim > New > Animation resource file.

4.Fade_in.xml and fade_out.xml has been added.

5.Click on Fade_in.xml.

6.Click on fade_out.xml.

7.Go to MainActivity.java. Add a line of code overridePendingTransition().

8.Go to activity_main.xml.

9.Go to activity_second.xml.

10.Run it on the live device.

Complete Code Fade in Fade out Animation Effect to Android App


package com.sabhithpkcmnr.screenonapp;
import ...
public class MainActivity extends AppCompatActivity {
    private static int WELCOME_TIMEOUT = 4000;
    protected void onCreate(Bundle savedInstanceState) {
        new Handler().postDelayed(new Runnable () {
            public void run() {
                Intent welcome = new Intent (MainActivity.this, SecondActivity.class);
        }, WELCOME_TIMEOUT);


package com.sabhithpkcmnr.screenonapp;
import ...
public class SecondActivity extends AppCompatActivity {
    protected void onCreate(Bundle SavedInstanceState){


<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schema.android.com/apk/res/android"
    android:fromAlpha="0.0" android:toAlpha="1.0" />


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


Related Articles


Please enter your comment!
Please enter your name here

Latest Articles