tags:

views:

42

answers:

1

I'd like to show a large green arrow in front of all other views when the user clicks a button. The arrow should fade in, stay there for 1-2 seconds and fade out again. How would I go about programming this? I've looked at the animation examples but would like to confirm the way forward before I dive into programming something that won't work :-):

  1. Draw the arrow-image as a bitmap, immediately make it invisible
  2. Fade it in ("alpha"-change animation)
  3. Let it stay for 2 seconds
  4. Fade it out (again, "alpha"-change animation)

Is this correct, or would you suggest something else?

"Mockup": http://screencast.com/t/MTMzZmVhNj

A: 

First of all, define the view you are going to show/hide (it will contain the big green arrow)... then, you can use a method like this (taken from this web site)...

public static Animation runFadeOutAnimationOn(Activity ctx, View target) {
  Animation animation = AnimationUtils.loadAnimation(ctx,
                                                     android.R.anim.fade_out);
  target.startAnimation(animation);
  return animation;
}

The method above is the fade-out animation... you can create another method using android.R.anim.fade_in in order to create the fade-in animation. So, as Mayra, the best layout would be a FrameLayout which gives you the freedom of positioning the views arbitrary.

Cristian
Great, thank you, I'll try that!
Nick