private Animation getAnimationSet(boolean fromXML) { if (fromXML) { Animation animation = AnimationUtils.loadAnimation(this, R.anim.view_animation); return animation; } else { AnimationSet innerAnimationSet = new AnimationSet(true); innerAnimationSet.setInterpolator(new BounceInterpolator()); innerAnimationSet.setStartOffset(1000); innerAnimationSet.addAnimation(getScaleAnimation()); innerAnimationSet.addAnimation(getTranslateAnimation()); AnimationSet animationSet = new AnimationSet(true); animationSet.setInterpolator(new LinearInterpolator()); animationSet.addAnimation(getAlphaAnimation()); animationSet.addAnimation(getRotateAnimation()); animationSet.addAnimation(innerAnimationSet); return animationSet; } }
public A setStartOffset(long startOffset) { animSet.setStartOffset(startOffset); return this; }
private void pageOtherToThreeAnim() { AnimationSet as = new AnimationSet(false); TranslateAnimation tAnimationIcon = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0.3f, TranslateAnimation.RELATIVE_TO_SELF, 0f); tAnimationIcon.setDuration(700); tAnimationIcon.setFillAfter(true); tAnimationIcon.setInterpolator(new OvershootInterpolator()); as.addAnimation(tAnimationIcon); AlphaAnimation aAnimationIcon = new AlphaAnimation(0f, 1f); aAnimationIcon.setDuration(700); aAnimationIcon.setFillAfter(true); as.addAnimation(aAnimationIcon); as.setStartOffset(300); page1AppIcon.startAnimation(as); page6Success.getBackground().setAlpha(255); page6Success.startAnimation(as); }
animationSet.setStartOffset(startDelay); animationSet.addAnimation(showAnimation); animationSet.addAnimation(translateAnimation);
private AnimationSet getOutSet() { AnimationSet outSet = new AnimationSet(true); RotateAnimation animOut1 = new RotateAnimation( 0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); ScaleAnimation animOut2 = new ScaleAnimation( 1.0f, 0.0f, 1.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); outSet.addAnimation(animOut1); outSet.addAnimation(animOut2); outSet.setDuration(1000); outSet.setStartOffset(1000); outSet.setFillAfter(true); return outSet; }
@Override public Animation createOptionShowAnimation(OptionButton optionButton, int index) { float fromX,fromY; AnimationSet animationSet = new AnimationSet(true); if (index < 3){ fromX = getYMenuButton().getX() - optionButton.getX(); fromY = getYMenuButton().getY() - optionButton.getY(); }else if (index < 6){ fromX = getOptionButtonList().get(0).getX() - optionButton.getX(); fromY = getOptionButtonList().get(0).getY() - optionButton.getY(); animationSet.setStartOffset(getOptionSD_AnimationDuration() ); }else { int oldIndex = index % 5; fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX(); fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY(); animationSet.setStartOffset(getOptionSD_AnimationDuration() ); } TranslateAnimation translateAnimation= new TranslateAnimation( fromX ,0 ,fromY ,0); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation); animationSet.setInterpolator(new LinearInterpolator()); return animationSet; }
@Override public Animation createOptionShowAnimation(OptionButton optionButton, int index) { float fromX,fromY; AnimationSet animationSet = new AnimationSet(true); if (index < 3){ fromX = getYMenuButton().getX() - optionButton.getX(); fromY = getYMenuButton().getY() - optionButton.getY(); }else if (index < 6){ fromX = getOptionButtonList().get(0).getX() - optionButton.getX(); fromY = getOptionButtonList().get(0).getY() - optionButton.getY(); animationSet.setStartOffset(getOptionSD_AnimationDuration() ); }else { int oldIndex = index % 5; fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX(); fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY(); animationSet.setStartOffset(getOptionSD_AnimationDuration() ); } TranslateAnimation translateAnimation= new TranslateAnimation( fromX ,0 ,fromY ,0); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation); animationSet.setInterpolator(new LinearInterpolator()); return animationSet; }
@Override public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) { AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation= new TranslateAnimation( 0 ,getYMenuButton().getX() - optionButton.getX() ,0 ,getYMenuButton().getY() - optionButton.getY() ); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(1,0); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(translateAnimation); animationSet.addAnimation(alphaAnimation); //设置动画延时 animationSet.setStartOffset(60*(getOptionPositionCount() - index)); return animationSet; } }
@Override public Animation createOptionShowAnimation(OptionButton optionButton, int index) { AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation= new TranslateAnimation( getYMenuButton().getX() - optionButton.getX() ,0 ,getYMenuButton().getY() - optionButton.getY() ,0); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation); //为不同的Option设置延时 if (index % 2 == 1) { animationSet.setStartOffset(getOptionSD_AnimationDuration()/2); } return animationSet; }
@Override public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) { AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation= new TranslateAnimation( 0 ,getYMenuButton().getX() - optionButton.getX() ,0 ,getYMenuButton().getY() - optionButton.getY() ); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(1,0); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(translateAnimation); animationSet.addAnimation(alphaAnimation); //为不同的Option设置延时 if (index % 2 == 0) { animationSet.setStartOffset(getOptionSD_AnimationDuration()/2); } return animationSet; } }
@Override public Animation createOptionShowAnimation(OptionButton optionButton, int index) { float fromX,fromY; AnimationSet animationSet = new AnimationSet(true); if (index < 3){ fromX = getYMenuButton().getX() - optionButton.getX(); fromY = getYMenuButton().getY() - optionButton.getY(); }else { int oldIndex = (index - 3) / 2; fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX(); fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY(); //设置冒出动画延时 animationSet.setStartOffset(getOptionSD_AnimationDuration()); } TranslateAnimation translateAnimation= new TranslateAnimation( fromX ,0 ,fromY ,0); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation); animationSet.setInterpolator(new LinearInterpolator()); return animationSet; }
@Override public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) { AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation= new TranslateAnimation( 0 ,getYMenuButton().getX() - optionButton.getX() ,0 ,getYMenuButton().getY() - optionButton.getY() ); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(1,0); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(translateAnimation); animationSet.addAnimation(alphaAnimation); //为不同的Option设置延时 if (index % 2 == 0) { animationSet.setStartOffset(getOptionSD_AnimationDuration()/2); } return animationSet; } }
@Override public Animation createOptionShowAnimation(OptionButton optionButton, int index) { AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation= new TranslateAnimation( getYMenuButton().getX() - optionButton.getX() ,0 ,getYMenuButton().getY() - optionButton.getY() ,0); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation); //为不同的Option设置延时 if (index % 2 == 1) { animationSet.setStartOffset(getOptionSD_AnimationDuration()/2); } return animationSet; }
@Override public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) { AnimationSet animationSet = new AnimationSet(true); TranslateAnimation translateAnimation= new TranslateAnimation( 0 ,getYMenuButton().getX() - optionButton.getX() ,0 ,getYMenuButton().getY() - optionButton.getY() ); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(1,0); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(translateAnimation); animationSet.addAnimation(alphaAnimation); //设置动画延时 animationSet.setStartOffset(60*(getOptionPositionCount() - index)); return animationSet; } }
@Override public Animation createOptionShowAnimation(OptionButton optionButton, int index) { float fromX,fromY; AnimationSet animationSet = new AnimationSet(true); if (index < 3){ fromX = getYMenuButton().getX() - optionButton.getX(); fromY = getYMenuButton().getY() - optionButton.getY(); }else { int oldIndex = (index - 3) / 2; fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX(); fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY(); //设置冒出动画延时 animationSet.setStartOffset(getOptionSD_AnimationDuration()); } TranslateAnimation translateAnimation= new TranslateAnimation( fromX ,0 ,fromY ,0); translateAnimation.setDuration(getOptionSD_AnimationDuration()); AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(getOptionSD_AnimationDuration()); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation); animationSet.setInterpolator(new LinearInterpolator()); return animationSet; }
toY = getYMenuButton().getY() - optionButton.getY(); if (getOptionButtonCount() > 3) { animationSet.setStartOffset(getOptionSD_AnimationDuration());
toY = getYMenuButton().getY() - optionButton.getY(); if (getOptionButtonCount() > 3) { animationSet.setStartOffset(getOptionSD_AnimationDuration());
animationSet.setStartOffset(30*index);
set2.setInterpolator(new AccelerateDecelerateInterpolator()); set2.setDuration(DURATION); set2.setStartOffset(DELAY); set2.setFillAfter(true); set3.setInterpolator(new AccelerateDecelerateInterpolator()); set3.setDuration(DURATION); set3.setStartOffset(2 * DELAY); set3.setFillAfter(true); setMic.setInterpolator(new AccelerateDecelerateInterpolator()); setMic.setDuration(DURATION); setMic.setStartOffset(3 * DELAY); setMic.setFillAfter(true);
animationSet.setStartOffset(30*index); animationSet.start(); animationSet.startNow();