mAnimationSet.addAnimation(translateAnim); mAnimationSet.addAnimation(alphaAnim); mAnimationSet.setDuration(mDuration); mAnimationSet.setAnimationListener(new Animation.AnimationListener() { @Override
public void toggle() { TranslateAnimation anim=null; AnimationSet set=new AnimationSet(true); isOpen=!isOpen; if (isOpen) { setVisibility(View.VISIBLE); anim=new TranslateAnimation(0.0f, 0.0f, getHeight(), 0.0f); } else { anim=new TranslateAnimation(0.0f, 0.0f, 0.0f, getHeight()); anim.setAnimationListener(collapseListener); set.addAnimation(fadeOut); } set.addAnimation(anim); set.setDuration(speed); set.setInterpolator(new AccelerateInterpolator(1.0f)); startAnimation(set); }
animationSet.addAnimation(scaleAnimation); animationSet.addAnimation(rotateAnimation); animationSet.setDuration(1500);
private void moveViewToScreenCenter( final View view ){ DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics( dm ); int originalPos[] = new int[2]; view.getLocationOnScreen( originalPos ); int xDelta = (dm.widthPixels - view.getMeasuredWidth() - originalPos[0])/2; int yDelta = (dm.heightPixels - view.getMeasuredHeight() - originalPos[1])/2; AnimationSet animSet = new AnimationSet(true); animSet.setFillAfter(true); animSet.setDuration(1000); animSet.setInterpolator(new BounceInterpolator()); TranslateAnimation translate = new TranslateAnimation( 0, xDelta , 0, yDelta); animSet.addAnimation(translate); ScaleAnimation scale = new ScaleAnimation(1f, 2f, 1f, 2f, ScaleAnimation.RELATIVE_TO_PARENT, .5f, ScaleAnimation.RELATIVE_TO_PARENT, .5f); animSet.addAnimation(scale); view.startAnimation(animSet); }
private void onCloseAnimation() { //rotate = new RotateAnimation(360, 0, xPosition, yPosition); scale = new ScaleAnimation(1, 0, 1, 0, xPosition, yPosition); scale.setInterpolator(new AccelerateInterpolator()); move = new TranslateAnimation(0, xSource-xPosition, 0, ySource-yPosition); spriteAnimation = new AnimationSet(true); //spriteAnimation.addAnimation(rotate); spriteAnimation.addAnimation(scale); spriteAnimation.addAnimation(move); spriteAnimation.setDuration(animationSpeed); startAnimation(spriteAnimation); }
mAnimationSet.addAnimation(translateAnim); mAnimationSet.addAnimation(alphaAnim); mAnimationSet.setDuration(mDuration); mAnimationSet.setAnimationListener(new Animation.AnimationListener() { @Override
private void onOpenAnimation() { //rotate = new RotateAnimation(0, 360, xPosition, yPosition); //rotate.setRepeatMode(Animation.REVERSE); //rotate.setRepeatCount(Animation.INFINITE); scale = new ScaleAnimation(0, 1, 0, 1, xPosition, yPosition); //scale.setRepeatMode(Animation.REVERSE); //scale.setRepeatCount(Animation.INFINITE); scale.setInterpolator(new DecelerateInterpolator()); move = new TranslateAnimation(xSource-xPosition, 0, ySource-yPosition, 0); spriteAnimation = new AnimationSet(true); //spriteAnimation.addAnimation(rotate); spriteAnimation.addAnimation(scale); spriteAnimation.addAnimation(move); spriteAnimation.setDuration(animationSpeed); startAnimation(spriteAnimation); } private void onCloseAnimation() {
set.addAnimation(translateAnimationY); set.addAnimation(translateAnimationX); set.setDuration(800);// 动画的执行时间 set.setAnimationListener(new Animation.AnimationListener() { @Override
public void animar(AnimationSet lista) { ImageView img = (ImageView) findViewById(R.id.img); // 2 segundos lista.setDuration(2000); // Manter o efeito no final da animação lista.setFillAfter(true); img.startAnimation(lista); // Inverte o flag para na próxima vez utilizar a animação inversa flag = !flag; }
@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);
AnimationSet set = new AnimationSet(true); Animation anim = new ScaleAnimation(1f, 0f, 1f, 0f, b, a); Animation animT = new TranslateAnimation(0f, b, 0f, a); set.addAnimation(anim); set.addAnimation(animT); set.setDuration(130); view.startAnimation(set);
@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);
public Animation showAnimation() { AnimationSet set = new AnimationSet(true); Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f); Animation scaleAnimation = new ScaleAnimation(0.1f, 1f, 0.1f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); set.setDuration(200); set.setInterpolator(new DecelerateInterpolator()); set.addAnimation(alphaAnimation); set.addAnimation(scaleAnimation); return set; }
@Override public Animation hideAnimation() { AnimationSet set = new AnimationSet(true); Animation alphaAnimation = new AlphaAnimation(1.0f, 0.0f); Animation scaleAnimation = new ScaleAnimation(1.0f, 0.1f, 1.0f, 0.1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); set.setDuration(200); set.setInterpolator(new DecelerateInterpolator()); set.addAnimation(alphaAnimation); set.addAnimation(scaleAnimation); return set; } }
TranslateAnimation translateAnim = new TranslateAnimation(0, desX, 0, desY); ScaleAnimation scaleAnim = new ScaleAnimation(1, 0.2f, 1, 1Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f); AnimationSet set = new AnimationSet(false); set.addAnimation(translateAnim); set.addAnimation(scaleAnim); set.setFillEnabled(true); set.setFillAfter(true); set.setDuration(300); mView.startAnimation(set);
AnimationSet animation = new AnimationSet(true); animation.addAnimation(new AlphaAnimation(0.0F, 1.0F)); animation.addAnimation(new ScaleAnimation(0.8f, 1, 0.8f, 1)); // Change args as desired animation.setDuration(300); mView.startAnimation(animation);
private Animation scaleSmallAnim(int duration) { AnimationSet animset = new AnimationSet(true); ScaleAnimation scaleAnim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); AlphaAnimation alphaAnim = new AlphaAnimation(1.0f, 0.0f); animset.addAnimation(scaleAnim); animset.addAnimation(alphaAnim); animset.setDuration(duration); animset.setFillAfter(true); return animset; }
private Animation createLogoAnim() { final ScaleAnimation tvScaleAnim = new ScaleAnimation(1.0f, 1.3f, 1.0f, 1.3f , Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5f); final TranslateAnimation tvTranslateAnim = new TranslateAnimation(0, 0, 0, -40); final AnimationSet tvAnimationSet = new AnimationSet(true); tvAnimationSet.addAnimation(tvScaleAnim); tvAnimationSet.addAnimation(tvTranslateAnim); tvAnimationSet.setDuration(3000); tvAnimationSet.setFillAfter(true); return tvAnimationSet; }
private Animation scaleBigAnim(int duration) { AnimationSet animset = new AnimationSet(true); ScaleAnimation scaleAnim = new ScaleAnimation(1.0f, 2.0f, 1.0f, 2.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); AlphaAnimation alphaAnim = new AlphaAnimation(1.0f, 0.0f); animset.addAnimation(scaleAnim); animset.addAnimation(alphaAnim); animset.setDuration(duration); animset.setFillAfter(true); return animset; }
private Animation addAnimation(int duration, Animation.AnimationListener animationListener) { AnimationSet animationSet = new AnimationSet(true); Animation alphaAnimation = new AlphaAnimation(1, 0); alphaAnimation.setFillAfter(true); animationSet.addAnimation(alphaAnimation); Animation largeAnimation = new ScaleAnimation(0f, 1.0f, 0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); largeAnimation.setFillAfter(true); animationSet.addAnimation(largeAnimation); animationSet.setDuration(duration); animationSet.setAnimationListener(animationListener); animationSet.setFillAfter(true); return animationSet; }