Thursday, April 7, 2011

Performing Animation in Android


Step1: create anim folder under res directory in ur project.

Step2: create an slideleft.xml file

Step3: type the following code in that file

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="400" />
</set>

step 4: similarly create slideright.xml

step5: use the above code, but change the following

<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="400" />

step 6:

target.startAnimation(AnimationUtils.loadAnimation(HomeScreen.this, R.anim.slide_left));

perfroming fadein operation, just add the following code in fadein.xml file

<?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="300" />

similarly for fade out too

<?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:duration="300" />

2 comments:

  1. Hi Ganesh, I'm glad to see ur examples and its very nice. But from my suggesstion please add screen shots for every post so that It will convey the easy way u want to.

    ReplyDelete
  2. What type of camera is this? That is certainly a
    great good quality.
    quick payday loans
    Take a look at my web page : check it out

    ReplyDelete

Notification in Android Using AlarmManager, BoradCastReceiver & Services

    Our aim is to show notification message to user in a specific time.     Say For example , I have planned to show Notification ...