private void initAnim() { long duration = 300; long durationS = 160; float alpha = 0.3f; AccelerateInterpolator accInterpolator = new AccelerateInterpolator(); tab_left = new TranslateAnimation(tabW, 0, 0, 0); tab_right = new TranslateAnimation(0, tabW, 0, 0); tab_alpha_1 = new AlphaAnimation(1.0f, alpha); tab_alpha_2 = new AlphaAnimation(alpha, 1.0f); pop_in = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_out = new ScaleAnimation( 1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_in.setDuration(durationS); pop_in.setInterpolator(accInterpolator); pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN)); pop_out.setDuration(durationS); pop_out.setInterpolator(accInterpolator); pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT)); tab_left.setFillAfter(true); tab_left.setFillEnabled(true); tab_left.setDuration(duration); tab_left.setInterpolator(accInterpolator); tab_right.setFillAfter(true); tab_right.setFillEnabled(true); tab_right.setDuration(duration); tab_right.setInterpolator(accInterpolator); tab_alpha_1.setFillAfter(true); tab_alpha_1.setFillEnabled(true); tab_alpha_1.setDuration(duration); tab_alpha_1.setInterpolator(accInterpolator); tab_alpha_2.setFillAfter(true); tab_alpha_2.setFillEnabled(true); tab_alpha_2.setDuration(duration); tab_alpha_2.setInterpolator(accInterpolator); AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha); alphaInit.setFillAfter(true); alphaInit.setFillEnabled(true); tv_tab_box.startAnimation(alphaInit); }
private Animation getDismissAnimation() { if (this.getAnimation() == SuperToast.Animations.FLYIN) { TranslateAnimation translateAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, .75f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(translateAnimation); animationSet.addAnimation(alphaAnimation); animationSet.setInterpolator(new AccelerateInterpolator()); animationSet.setDuration(250); return animationSet; } else if (this.getAnimation() == SuperToast.Animations.SCALE) { ScaleAnimation scaleAnimation = new ScaleAnimation( 1.0f, 0.9f, 1.0f, 0.9f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(scaleAnimation); animationSet.addAnimation(alphaAnimation); animationSet.setInterpolator(new DecelerateInterpolator()); animationSet.setDuration(250); return animationSet; } else if (this.getAnimation() == SuperToast.Animations.POPUP) { TranslateAnimation translateAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.1f); AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(translateAnimation); animationSet.addAnimation(alphaAnimation); animationSet.setInterpolator(new DecelerateInterpolator()); animationSet.setDuration(250); return animationSet; } else { AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); alphaAnimation.setDuration(500); alphaAnimation.setInterpolator(new AccelerateInterpolator()); return alphaAnimation; } }