AnimationSet a = new AnimationSet(true); float fullAlpha = centralIcon.getAlpha(); AlphaAnimation alpha[] = new AlphaAnimation[3];//array of 3 alpha animations alpha[0] = new AlphaAnimation(fullAlpha, 0);//first fade to 0 alpha[0].setDuration(300); alpha[1] = new AlphaAnimation(0, fullAlpha);//then fade back to full alpha[1].setDuration(300); alpha[1].setStartOffset(300);//start after alpha[0] finishes alpha[2] = new AlphaAnimation(fullAlpha, 0);//then fade back to 0 alpha[2].setDuration(300); alpha[2].setStartOffset(600);//start after alpha[0] and alpha[1] finish for(AlphaAnimation current : alpha) a.addAnimation(current);//add all the animations to the set a.setInterpolator(new LinearInterpolator()); centralIcon.setAnimation(a);//attach the animation set to the view a.startNow();//start the animation set
iv1 = (ImageView) findViewById(R.id.imageView1); //first image iv2 = (ImageView) findViewById(R.id.imageView2); // second image Animation iv1anim = AnimationUtils.loadAnimation(this, R.anim.abc_slide_out_bottom); Animation iv2anim = AnimationUtils.loadAnimation(this, R.anim.abc_slide_in_bottom); // the animations are in-built iv1.setAnimation(iv1anim); // setting the respective anims iv2.setAnimation(iv2anim);// setting the respective anims iv1anim.setStartTime(0); // it will start quickly iv2anim.setStartOffset(iv1anim.getDuration());// its going to delay,for the duration // of the first image. in millieseconds,so there will be no seconds wait final AnimationSet anim = new AnimationSet(false); anim.addAnimation(iv1anim); // the rest is cheese anim.addAnimation(iv2anim); anim.startNow();
snowAnimationView.setTag(R.id.tag_countdown_timer, animationSet); snowAnimationView.setAnimation(animationSet); animationSet.startNow();
animationSet.startNow(); return animationSet;