1

Trying to add a help overlay to our app. This overlay is a RelativeLayout with translucent background and it contains a few TextView and a few ImageView child elements. Now, i want each of the TextView / ImageView to fade-in one after another.

I am using a fade-in animation set (defined in the XML) and calling .startAnimation() on each view in the AnimationListener's OnAnimationEnd method. So, when the first View is done fading-in, i call the startAnimation method on the next view to be faded-in. I am using the same Animation object (animationFadeIn) as argument to startAnimation of all the views. Like so:

...
Animation animationFadeIn = AnimationUtils.loadAnimation(this.context, R.anim.fadein);
...
AnimationListener animationInListener = new AnimationListener(){
    @Override
    public void onAnimationEnd(Animation animation) {
      animation_activity++;
      switch(animation_activity) {
        case SHOW_TEXT_DROP:
            txtDrop.startAnimation(animationFadeIn);
            break;
        case SHOW_TEXT_SEND:
            txtSend.startAnimation(animationFadeIn);
            break;
        case SHOW_IMAGE_TOUCH:
            imgTouch.startAnimation(animationFadeIn);
            break;
        case SHOW_TEXT_DISABLE:
            txtDisable.startAnimation(animationFadeIn);
            break;
      }
    }
};

For fade-in animation, i referred this tutorial

Now, here's the problem:

  • First view fades-in
  • Second view fades-in, but first view fades-in again as well along with it
  • Same continues until all the views are done fading-in

Also, how do i add some delay before the next view fades-in setStartOffset ?

UPDATE

I noticed that if i create a second Animation object by

animationFadeIn2 = AnimationUtils.loadAnimation(this.context, R.anim.fadein);

and then use it for the startAnimation of other element, then it does not create this issue. So, i believe, there must be some property to be set on the Animation object so as to avoid this ?

Madhur
  • 1,971
  • 1
  • 21
  • 29

1 Answers1

1

I finally went ahead and created multiple Animation objects for each of the element. That solves the issue for time-being. It may not be the right/best approach.

Madhur
  • 1,971
  • 1
  • 21
  • 29