Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Created November 21, 2010 21:30
Show Gist options
  • Save mikeplate/709171 to your computer and use it in GitHub Desktop.
Save mikeplate/709171 to your computer and use it in GitHub Desktop.
Animation sample for Android
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(100);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(2000);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f);
ViewGroup view = (ViewGroup)getWindow().getDecorView();
if (view.getChildCount() == 1 && (view.getChildAt(0) instanceof LinearLayout)) {
LinearLayout layout = (LinearLayout)view.getChildAt(0);
layout.setLayoutAnimation(controller);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment