List of usage examples for android.view.animation AnimationSet AnimationSet
public AnimationSet(boolean shareInterpolator)
From source file:Main.java
public static void postAnimationBottom(final View childLayout, int delay, final int duration) { int visibility = childLayout.getVisibility(); if (visibility != View.VISIBLE) { return;/*from w w w . j av a 2 s . com*/ } childLayout.setVisibility(View.INVISIBLE); childLayout.postDelayed(new Runnable() { @Override public void run() { childLayout.setVisibility(View.VISIBLE); AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(duration); animationSet.setInterpolator(new AccelerateDecelerateInterpolator()); int pivotXType = Animation.RELATIVE_TO_SELF; animationSet.addAnimation( new TranslateAnimation(pivotXType, 0, pivotXType, 0, pivotXType, 1, pivotXType, 0)); animationSet.addAnimation(new AlphaAnimation(0, 1)); childLayout.startAnimation(animationSet); } }, delay); }
From source file:Main.java
public static void animation(View paramView) { TranslateAnimation localTranslateAnimation = new TranslateAnimation(2, 1.0F, 2, 0.0F, 2, 0.0F, 2, 0.0F); AlphaAnimation localAlphaAnimation = new AlphaAnimation(0.0F, 1.0F); AnimationSet localAnimationSet = new AnimationSet(false); localAnimationSet.addAnimation(localTranslateAnimation); localAnimationSet.addAnimation(localAlphaAnimation); animation(paramView, localAnimationSet, 1000L, 0L); }
From source file:Main.java
public static void shrinkToLeft(FragmentActivity activity, View view, AnimationListener listener) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int screenHeight = displaymetrics.heightPixels; int screenWidth = displaymetrics.widthPixels; AnimationSet animation = new AnimationSet(true); float pivotX = view.getWidth() / 2; float pivotY = view.getHeight() / 2; ScaleAnimation anim = new ScaleAnimation(1f, 0.8f, 1f, 0.8f, pivotX, pivotY); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(200);/*from www . j av a 2 s . c o m*/ anim.setStartOffset(200); //anim.setFillAfter(true); animation.addAnimation(anim); TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) -(screenWidth - view.getWidth()), 0.0f, 0.0f); anim.setInterpolator(new LinearInterpolator()); animTrans.setDuration(400); //animTrans.setStartOffset(300); animation.addAnimation(animTrans); if (listener != null) animation.setAnimationListener(listener); view.startAnimation(animation); }
From source file:Main.java
public static void enlargeToRight(FragmentActivity activity, View view, AnimationListener listener) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int screenHeight = displaymetrics.heightPixels; int screenWidth = displaymetrics.widthPixels; AnimationSet animation = new AnimationSet(true); float pivotX = view.getWidth() / 2; float pivotY = view.getHeight() / 2; ScaleAnimation anim = new ScaleAnimation(0.8f, 1f, 0.8f, 1f, pivotX, pivotY); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(200);/*from w ww .j a v a 2 s. com*/ anim.setStartOffset(200); //anim.setFillAfter(true); animation.addAnimation(anim); TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) (screenWidth - view.getWidth()), 0.0f, 0.0f); anim.setInterpolator(new LinearInterpolator()); animTrans.setDuration(400); //animTrans.setStartOffset(300); animation.addAnimation(animTrans); if (listener != null) animation.setAnimationListener(listener); view.startAnimation(animation); }
From source file:Main.java
public static AnimationSet RotateAndFadeInAnimation() { AlphaAnimation fade_in = new AlphaAnimation(0.2f, 1f); fade_in.setDuration(400);/*www . ja v a 2s . co m*/ fade_in.setStartOffset(0); fade_in.setFillAfter(true); ScaleAnimation expand = new ScaleAnimation(0.2f, 1, 0.2f, 1, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); expand.setDuration(500); expand.setStartOffset(0); expand.setFillAfter(true); RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); rotate.setDuration(500); rotate.setStartOffset(0); // rotate.setInterpolator(new LinearInterpolator()); rotate.setFillAfter(true); AnimationSet Reload = new AnimationSet(true); Reload.addAnimation(fade_in); Reload.addAnimation(expand); Reload.addAnimation(rotate); Reload.setInterpolator(new DecelerateInterpolator(1.3f)); return Reload; }
From source file:Main.java
public static AnimationSet RotateAndFadeOutAnimation() { AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f); fade_out.setDuration(500);/*from w w w .j a va 2 s. c o m*/ fade_out.setStartOffset(0); fade_out.setFillAfter(true); ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); shrink.setDuration(400); shrink.setStartOffset(0); shrink.setFillAfter(true); RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); rotate.setDuration(500); rotate.setStartOffset(0); rotate.setInterpolator(new LinearInterpolator()); rotate.setFillAfter(true); AnimationSet Reload = new AnimationSet(true); Reload.addAnimation(fade_out); Reload.addAnimation(shrink); Reload.addAnimation(rotate); Reload.setInterpolator(new AccelerateInterpolator(1.1f)); return Reload; }
From source file:Main.java
protected static void show(final View view) { Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setStartOffset(500);/*from w w w. j a va 2s . c om*/ fadeIn.setDuration(500); Animation collapse = new ScaleAnimation(1, 1, 0, 1); collapse.setDuration(500); AnimationSet animation = new AnimationSet(false); animation.setInterpolator(new AccelerateInterpolator()); animation.addAnimation(collapse); animation.addAnimation(fadeIn); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); view.startAnimation(animation); }
From source file:Main.java
public static void addAnimation(View view, Animation animation, boolean first) { Animation previousAnimation = view.getAnimation(); if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) { if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME) view.startAnimation(animation); else/*from www .j a v a 2 s . co m*/ view.setAnimation(animation); return; } if (!(previousAnimation instanceof AnimationSet)) { AnimationSet newSet = new AnimationSet(false); newSet.addAnimation(previousAnimation); previousAnimation = newSet; } // Remove old of same type // AnimationSet set = (AnimationSet) previousAnimation; for (int i = 0; i < set.getAnimations().size(); i++) { Animation anim = set.getAnimations().get(i); if (anim.getClass() == animation.getClass()) { set.getAnimations().remove(i); break; } } // Add this (first if it is a scale animation ,else at end) if (animation instanceof ScaleAnimation || first) { set.getAnimations().add(0, animation); } else { set.getAnimations().add(animation); } animation.startNow(); view.setAnimation(set); }
From source file:com.example.demo_highlights.slidingmenu.fragment.PageFragment1.java
private LayoutAnimationController getListAnim() { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(200);//from w w w. j a va 2 s . c o m 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(200); set.addAnimation(animation); Animation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); inAnimation.setDuration(200); inAnimation.setFillAfter(true); set.addAnimation(inAnimation); Animation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); outAnimation.setDuration(200); outAnimation.setFillAfter(true); // LayoutAnimationController inController = new LayoutAnimationController(inAnimation, 0.3f); // LayoutAnimationController outController = new LayoutAnimationController(outAnimation, 0.3f); LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); return controller; }
From source file:Main.java
static void addAnimation(View view, Animation animation, boolean first) { Animation previousAnimation = view.getAnimation(); if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) { if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME) view.startAnimation(animation); else//from w ww .j a v a 2s . c o m view.setAnimation(animation); return; } if (!(previousAnimation instanceof AnimationSet)) { AnimationSet newSet = new AnimationSet(false); newSet.addAnimation(previousAnimation); previousAnimation = newSet; } // Remove old of same type // AnimationSet set = (AnimationSet) previousAnimation; for (int i = 0; i < set.getAnimations().size(); i++) { Animation anim = set.getAnimations().get(i); if (anim.getClass() == animation.getClass()) { set.getAnimations().remove(i); break; } } // Add this (first if it is a scale animation ,else at end) if (animation instanceof ScaleAnimation || first) { set.getAnimations().add(0, animation); } else { set.getAnimations().add(animation); } animation.startNow(); view.setAnimation(set); }