List of usage examples for android.view.animation AnimationSet addAnimation
public void addAnimation(Animation a)
From source file:Main.java
public static Animation shakeAnimation(int X) { AnimationSet set = new AnimationSet(true); Animation anim1 = getTranslateAnimation(0, -200, 0, 0, 100); anim1.setStartOffset(100);//w w w. j av a2s . c om set.addAnimation(anim1); Animation anim2 = getTranslateAnimation(-200, 400, 0, 0, 200); anim2.setStartOffset(300); set.addAnimation(anim2); Animation anim3 = getTranslateAnimation(400, -200, 0, 0, 200); anim3.setStartOffset(500); set.addAnimation(anim3); Animation anim4 = getTranslateAnimation(-200, 0, 0, 0, 100); anim4.setStartOffset(600); set.addAnimation(anim4); set.setFillAfter(true); set.setDuration(640); return set; }
From source file:Main.java
public static void setButtonEffect(View view) { AnimationSet animationSet = new AnimationSet(true); ScaleAnimation scaleAnimation = new ScaleAnimation(1.02f, 1.01f, 1.02f, 1.01f); scaleAnimation.setDuration(300);/*from w ww . j a va 2 s.c o m*/ animationSet.addAnimation(scaleAnimation); view.startAnimation(animationSet); }
From source file:Main.java
protected static void show(final View view) { Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setStartOffset(500);//from w ww. j a va 2 s . c o m 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
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/* www. j av a 2 s . 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); }
From source file:Main.java
public static AnimationSet flash(final android.view.animation.Animation.AnimationListener animationlistener) { final AnimationSet animationset = new AnimationSet(true); final AlphaAnimation alphaanimation = new AlphaAnimation(0F, 1F); alphaanimation.setStartOffset(500L); alphaanimation.setDuration(100L);// w w w. jav a 2 s. c o m animationset.addAnimation(alphaanimation); final AlphaAnimation alphaanimation1 = new AlphaAnimation(1F, 0F); alphaanimation1.setDuration(100L); alphaanimation1.setStartOffset(1200L); animationset.addAnimation(alphaanimation1); animationset.setAnimationListener(animationlistener); return animationset; }
From source file:com.capricorn.ArcMenu.java
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) { AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)); animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f)); animationSet.setDuration(duration);// ww w . ja va2s .c o m animationSet.setInterpolator(new DecelerateInterpolator()); animationSet.setFillAfter(true); return animationSet; }
From source file:net.evendanan.pushingpixels.PassengerFragmentSupport.java
@Nullable public static Animation onCreateAnimation(@NonNull Fragment passengerFragment, int transit, boolean enter, int nextAnim) { Log.d(TAG, "onCreateAnimation: transit: " + transit + ", enter: " + enter + ", nextAnim: " + nextAnim); final boolean validTransitionToModify = nextAnim == R.anim.ui_context_expand_add_in || nextAnim == R.anim.ui_context_expand_pop_out; if (!validTransitionToModify) return null; ScaleAnimation scale = null;/*from www . j ava 2 s . c o m*/ PointF originateViewCenterPoint = PointFCompat.getPointFromBundle(passengerFragment.getArguments(), EXTRA_ORIGINATE_VIEW_CENTER); PointF originateViewScale = PointFCompat.getPointFromBundle(passengerFragment.getArguments(), EXTRA_ORIGINATE_VIEW_SCALE); if (originateViewCenterPoint != null && originateViewScale != null) { Log.d(TAG, "originateViewCenterPoint: " + originateViewCenterPoint.toString()); if (enter && nextAnim == R.anim.ui_context_expand_add_in) { scale = new ScaleAnimation(originateViewScale.x, 1.0f, originateViewScale.y, 1.0f, ScaleAnimation.ABSOLUTE, originateViewCenterPoint.x, ScaleAnimation.ABSOLUTE, originateViewCenterPoint.y); } else if (!enter && nextAnim == R.anim.ui_context_expand_pop_out) { scale = new ScaleAnimation(1.0f, originateViewScale.x, 1.0f, originateViewScale.y, ScaleAnimation.ABSOLUTE, originateViewCenterPoint.x, ScaleAnimation.ABSOLUTE, originateViewCenterPoint.y); } } if (scale == null) { //no originate view, so I'll add generic scale-animation if (enter) { scale = new ScaleAnimation(0.4f, 1.0f, 0.4f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f); } else { scale = new ScaleAnimation(1.0f, 0.4f, 1.0f, 0.4f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f); } } scale.setDuration(passengerFragment.getResources().getInteger(android.R.integer.config_mediumAnimTime)); AnimationSet set = (AnimationSet) AnimationUtils .loadAnimation(passengerFragment.getActivity().getApplicationContext(), nextAnim); set.addAnimation(scale); return set; }
From source file:Main.java
public static void postAnimation(final View childLayout, int delay, final int duration) { int visibility = childLayout.getVisibility(); if (visibility != View.VISIBLE) { return;//from www . jav a2 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 OvershootInterpolator(0.8f)); int pivotXType = Animation.RELATIVE_TO_SELF; animationSet.addAnimation( new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0)); animationSet.addAnimation(new AlphaAnimation(0, 1)); childLayout.startAnimation(animationSet); } }, delay); }
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 a va 2s .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:com.tr4android.support.extension.widget.LabelView.java
private static Animation createAnimationSet(float fromAlpha, float toAlpha, int fromXDelta, int toXDelta) { AnimationSet anim = new AnimationSet(true); anim.addAnimation(new AlphaAnimation(fromAlpha, toAlpha)); anim.addAnimation(new TranslateAnimation(fromXDelta, toXDelta, 0, 0)); return anim;//from w ww . j av a2 s .c o m }