Step 1:

At first you have to create a folder named “anim” inside the “res” folder and copy these XML files inside it.

HyperSpace In.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="https://schemas</span>.android.com/apk/res/android"
android:duration="300"
android:fromAlpha="0.0"
android:startOffset="1200"
android:toAlpha="1.0" />
HyperSpace Out .xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="https://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<scale
android:duration="700"
android:fillAfter="false"
android:fillEnabled="true"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.4"
android:toYScale="0.6" />

<set android:interpolator="@android:anim/accelerate_interpolator" >
<scale
android:duration="400"
android:fillAfter="true"
android:fillBefore="false"
android:fillEnabled="true"
android:fromXScale="1.4"
android:fromYScale="0.6"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:toXScale="0.0"
android:toYScale="0.0" />

<rotate
android:duration="400"
android:fillAfter="true"
android:fillBefore="false"
android:fillEnabled="true"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:toDegrees="-45"
android:toYScale="0.0" />
</set>

</set>
Push Left in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="https://schemas.android.com/apk/res/android" >

<<span class="IL_AD" id="IL_AD7">translate</span>
android:duration="300"
android:fromXDelta="100%p"
android:toXDelta="0" />

<alpha
android:duration="300"
android:fromAlpha="0.0"
android:toAlpha="1.0" />

</set>
Push Left Out.xml

<?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”https://schemas.android.com/apk/res/android” > <translate android:duration=”300″ android:fromXDelta=”0″ android:toXDelta=”-100%p” /> <alpha android:duration=”300″ android:fromAlpha=”1.0″ android:toAlpha=”0.0″ /> </set>

push_up_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="https://schemas.android.com/apk/res/android" >

<translate
android:duration="300"
android:fromYDelta="100%p"
android:toYDelta="0" />

<alpha
android:duration="300"
android:fromAlpha="0.0"
android:toAlpha="1.0" />

</set>

push_up_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="https://schemas.android.com/apk/res/android" >

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

<alpha
android:duration="300"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>

 

Step 2:

then inside the layout folder  create animation_activity.xml.

animation_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >

<ViewFlipper
android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:flipInterval="2000" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Hello"
android:textSize="26sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="From"
android:textSize="26sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="CoderzHeaven"
android:textSize="26sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Heaven of all working Codes"
android:textSize="26sp" />
</ViewFlipper>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:text="Select the Animation to Apply" />

<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>

Step 3:

then inside the src folder (package folder)  create animation_activity.class and past the following code

animation_activity.java

package com.appsinfoway.animation;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.ViewFlipper;

import com.appsinfoway.loginscree.R;
//Apps infoway
public class MainActivity extends Activity implements
AdapterView.OnItemSelectedListener {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animation_activity);

mFlipper = ((ViewFlipper) this.findViewById(R.id.flipper));
mFlipper.startFlipping();

Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, mStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
s.setOnItemSelectedListener(this);
}

public void onItemSelected(AdapterView<?> parent, View v, int position,
long id) {
switch (position) {

case 0:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_up_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_up_out));
break;
case 1:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_out));
break;
case 2:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
break;
default:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.hyperspace_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.hyperspace_out));
break;
}
}

public void onNothingSelected(AdapterView<?> parent) {
}

private String[] mStrings = {"Push up", "Push left", "Cross fade",
"Hyperspace"};

private ViewFlipper mFlipper;

}

Thats it now Right Click on the project name and select Run As –> Android Application