Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sample application of diffrent types of Android Animations

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 375
    Comment on it

    In this sample application you will find different types of animations. For example :- Bounce, Fade In/out, Blink, Sequential Animation etc. If you want to use any animation in your app you just have to add that particular piece of code in your app and enjoy animation.

    Here i will show you an example of bounce animation. First you have to create an XML bounce.xml file in anim folder in res.

     <?xml version="1.0" encoding="utf-8"?>
     <set xmlns:android="http://schemas.android.com/apk/res/android"
     android:fillAfter="true"
     android:interpolator="@android:anim/bounce&#95;interpolator">
    
    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="0.0"
        android:toXScale="1.0"
        android:toYScale="1.0" />
    

    Now apply this bounce.xml file in you Activity Class like this

    public class BounceActivity extends Activity implements AnimationListener {
    
    ImageView imgPoster;
    Button btnStart;
    
    // Animation
    Animation animBounce;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity&#95;bounce);
    
        imgPoster = (ImageView) findViewById(R.id.imgLogo);
        btnStart = (Button) findViewById(R.id.btnStart);
    
        // load the animation
        animBounce = AnimationUtils.loadAnimation(getApplicationContext(),
                R.anim.bounce);
    
        // set animation listener
        animBounce.setAnimationListener(this);
    
        // button click event
        btnStart.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // start the animation
                imgPoster.setVisibility(View.VISIBLE);
                imgPoster.startAnimation(animBounce);
            }
        });
    
    }
    
    @Override
    public void onAnimationEnd(Animation animation) {
        // Take any action after completing the animation
    
        // check for zoom in animation
        if (animation == animBounce) {
        }
    
    }
    
    @Override
    public void onAnimationRepeat(Animation animation) {
        // TODO Auto-generated method stub
    
    }
    
    @Override
    public void onAnimationStart(Animation animation) {
        // TODO Auto-generated method stub
    
    }
    

    }

    Hope you will find it helpful .. :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: