Java Code Examples for android.view.animation.AnimationSet.setDuration()

The following are Jave code examples for showing how to use setDuration() of the android.view.animation.AnimationSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ExpandButton   File: ExpandButtonLayout.java   Source Code and License Vote up 7 votes
public void open() {

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(duration);
        animationSet.setAnimationListener(this);
        animationSet.setFillAfter(true);

        RotateAnimation rotateAnimation = new RotateAnimation(270, 360,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(rotateAnimation);
        Animation scaleAnimation = new ScaleAnimation(1.25f, 1f, 1.25f, 1f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(scaleAnimation);
        imageView.startAnimation(animationSet);


        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator animator1 = ObjectAnimator.ofInt(mLinearLayout, "width", 0, mLinearLayoutWidth);
        ObjectAnimator animator2 = ObjectAnimator.ofInt(mLinearLayout, "paddingLeft", 0, savePaddingLeft);
        ObjectAnimator animator3 = ObjectAnimator.ofInt(mLinearLayout, "paddingRight", 0, savePaddingRight);
        ObjectAnimator animator4 = ObjectAnimator.ofInt(mLinearLayout, "marginLeft", 0, saveMarginLeft);
        ObjectAnimator animator5 = ObjectAnimator.ofInt(mLinearLayout, "marginRight", 0, saveMarginRight);
        animatorSet.playTogether(animator1, animator2, animator3, animator4, animator5);
        animatorSet.setDuration(duration).start();

    }
 
Example 2
Project: Pocket-Plays-for-Twitch   File: AnimationService.java   Source Code and License Vote up 7 votes
public static void setAdapterInsertAnimation(final View aCard, int row, int height) {
	final int ANIMATION_DURATION = 650;
	final int BASE_DELAY = 50;

	TranslateAnimation translationAnimation = new TranslateAnimation(0,0, height,0);

	AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);

	final AnimationSet animationSet = new AnimationSet(true);
	animationSet.addAnimation(translationAnimation);
	animationSet.addAnimation(alphaAnimation);
	animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
	animationSet.setFillAfter(true);
	animationSet.setFillBefore(true);
	animationSet.setDuration(ANIMATION_DURATION + row * BASE_DELAY);

	aCard.setAnimation(animationSet);
}
 
Example 3
Project: QMUI_Android   File: QMUIBottomSheet.java   Source Code and License Vote up 6 votes
/**
 * BottomSheet升起动画
 */
private void animateUp() {
    if (mContentView == null) {
        return;
    }
    TranslateAnimation translate = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f
    );
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(translate);
    set.addAnimation(alpha);
    set.setInterpolator(new DecelerateInterpolator());
    set.setDuration(mAnimationDuration);
    set.setFillAfter(true);
    mContentView.startAnimation(set);
}
 
Example 4
Project: OSchina_resources_android   File: KJAnimations.java   Source Code and License Vote up 6 votes
public static Animation shakeAnimation(int X) {
    AnimationSet set = new AnimationSet(true);
    Animation anim1 = getTranslateAnimation(0, -200, 0, 0, 100);
    anim1.setStartOffset(100);
    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;
}
 
Example 5
Project: Pocket-Plays-for-Twitch   File: AnimationService.java   Source Code and License Vote up 6 votes
public static AnimationSet startAlphaHideAnimation(final View VIEW) {
	final int ANIMATION_DURATION = 350;

	final Animation mHideViewAnimation = new AlphaAnimation(1f, 0f);

	AnimationSet mAnimations = new AnimationSet(true);
	mAnimations.setDuration(ANIMATION_DURATION);
	mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
	mAnimations.addAnimation(mHideViewAnimation);
	mAnimations.setFillAfter(true);

       if(VIEW != null)
	    VIEW.startAnimation(mAnimations);

	return mAnimations;
}
 
Example 6
Project: Cable-Android   File: MicrophoneRecorderView.java   Source Code and License Vote up 5 votes
public void hide(float x) {
  this.lastPositionX = x;

  float offset          = getOffset(x);
  int   widthAdjustment = getWidthAdjustment();

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment,
                                                        Animation.ABSOLUTE, widthAdjustment,
                                                        Animation.RELATIVE_TO_SELF, -.25f,
                                                        Animation.RELATIVE_TO_SELF, -.25f);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}
 
Example 7
Project: Cable-Android   File: AttachmentTypeSelector.java   Source Code and License Vote up 5 votes
private void animateButtonIn(View button, int delay) {
  AnimationSet animation = new AnimationSet(true);
  Animation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
                                       Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.0f);

  animation.addAnimation(scale);
  animation.setInterpolator(new OvershootInterpolator(1));
  animation.setDuration(ANIMATION_DURATION);
  animation.setStartOffset(delay);
  button.startAnimation(animation);
}
 
Example 8
Project: RecyclerViewAnimation   File: MyLayoutAnimationHelper.java   Source Code and License Vote up 5 votes
/**
 * 旋转动画
 *
 * @return
 */
public static AnimationSet getAnimationSetRotation() {
    AnimationSet animationSet = new AnimationSet(true);

    RotateAnimation rotateAnimation = new RotateAnimation(30, 0, RELATIVE_TO_SELF, 0.5f, RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(400);
    rotateAnimation.setInterpolator(new DecelerateInterpolator());

    animationSet.addAnimation(rotateAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 9
Project: Cable-Android   File: HidingLinearLayout.java   Source Code and License Vote up 5 votes
public void show() {
  if (!isEnabled() || getVisibility() == VISIBLE) return;

  setVisibility(VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new ScaleAnimation(0, 1, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
  animation.addAnimation(new AlphaAnimation(0, 1));
  animation.setDuration(100);

  animateWith(animation);
}
 
Example 10
Project: RecyclerViewAnimation   File: MyLayoutAnimationHelper.java   Source Code and License Vote up 5 votes
/**
 * 从左侧进入,并带有弹性的动画
 *
 * @return
 */
public static AnimationSet getAnimationSetFromLeft() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, -1.0f, RELATIVE_TO_SELF, 0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(300);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    TranslateAnimation translateX2 = new TranslateAnimation(RELATIVE_TO_SELF, 0.1f, RELATIVE_TO_SELF, -0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX2.setStartOffset(300);
    translateX2.setInterpolator(new DecelerateInterpolator());
    translateX2.setDuration(50);

    TranslateAnimation translateX3 = new TranslateAnimation(RELATIVE_TO_SELF, -0.1f, RELATIVE_TO_SELF, 0f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX3.setStartOffset(350);
    translateX3.setInterpolator(new DecelerateInterpolator());
    translateX3.setDuration(50);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 1.0f);
    alphaAnimation.setDuration(400);
    alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());


    animationSet.addAnimation(translateX1);
    animationSet.addAnimation(translateX2);
    animationSet.addAnimation(translateX3);
    //animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 11
Project: stateLayout   File: FadeScaleViewAnimProvider.java   Source Code and License Vote up 5 votes
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;
}
 
Example 12
Project: RecyclerViewAnimation   File: MyLayoutAnimationHelper.java   Source Code and License Vote up 5 votes
/**
 * 缩小动画
 *
 * @return
 */
public static AnimationSet getAnimationSetScaleNarrow() {
    AnimationSet animationSet = new AnimationSet(true);

    ScaleAnimation scaleAnimation = new ScaleAnimation(2.1f, 1.0f, 2.1f, 1.0f, RELATIVE_TO_SELF, 0.5f, RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(400);

    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 13
Project: FLFloatingButton   File: ArcMenu.java   Source Code and License Vote up 5 votes
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);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}
 
Example 14
Project: FLFloatingButton   File: RayMenu.java   Source Code and License Vote up 5 votes
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);
	animationSet.setInterpolator(new DecelerateInterpolator());
	animationSet.setFillAfter(true);

	return animationSet;
}
 
Example 15
Project: RecyclerViewAnimation   File: MyLayoutAnimationHelper.java   Source Code and License Vote up 5 votes
/**
 * 从顶部进入
 *
 * @return
 */
public static AnimationSet getAnimationSetFromTop() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0,
            RELATIVE_TO_SELF, -2.5f, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(400);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    animationSet.addAnimation(translateX1);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 16
Project: JueDiQiuSheng   File: SplashActivity.java   Source Code and License Vote up 5 votes
public void btnTranslateLeft(View view,long duration) {
    AnimationSet as = new AnimationSet(true);
    as.setDuration(duration);
    TranslateAnimation ta = new TranslateAnimation(width,0, 0, 0);
    ta.setDuration(duration);
    as.addAnimation(ta);
    AlphaAnimation aa = new AlphaAnimation(0, 1);
    //持续时间
    aa.setDuration(duration);
    as.addAnimation(aa);
    view.startAnimation(as);
}
 
Example 17
Project: JueDiQiuSheng   File: SplashActivity.java   Source Code and License Vote up 5 votes
public void btnTranslateRight(View view,long duration) {

        AnimationSet as = new AnimationSet(true);
        as.setDuration(duration);
        TranslateAnimation ta = new TranslateAnimation(-width, 0, 0, 0);
        ta.setDuration(duration);
        as.addAnimation(ta);
        AlphaAnimation aa = new AlphaAnimation(0, 1);
        //持续时间
        aa.setDuration(duration);
        as.addAnimation(aa);
        view.startAnimation(as);
    }
 
Example 18
Project: AnnularMenuView   File: AnnularMenu.java   Source Code and License Vote up 5 votes
private Animation scaleSmallAnimation(int duration) {
    AnimationSet animationSet = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5F);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    animationSet.addAnimation(scaleAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(duration);
    animationSet.setFillAfter(true);
    return animationSet;
}
 
Example 19
Project: showroom-android   File: ShowroomActivity.java   Source Code and License Vote up 4 votes
private void showHelpOverlay() {
    if (animationsInProgress) return;
    animationsInProgress = true;
    titleLayout.bringToFront();
    helpLayout.setVisibility(View.VISIBLE);

    Animator showAnimation;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        showAnimation = ViewAnimationUtils.createCircularReveal(helpLayout, titleBtnHelpCenterX, titleBtnHelpCenterY, 0, screenDiagonalPx);
    } else {
        showAnimation = ObjectAnimator.ofFloat(helpLayout, "alpha", 0f, 1f);
    }
    showAnimation.setInterpolator(new AccelerateInterpolator());
    showAnimation.setDuration(250);
    showAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mainLayout.setVisibility(View.GONE);
            animationsInProgress = false;
            helpLayoutShown = true;
        }
    });
    showAnimation.start();

    int textMoveOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, getResources().getDisplayMetrics());

    AnimationSet helpHeaderAnimationSet = new AnimationSet(true);
    helpHeaderAnimationSet.addAnimation(new TranslateAnimation(0, 0, textMoveOffset, 0));
    helpHeaderAnimationSet.addAnimation(new AlphaAnimation(0, 1f));
    helpHeaderAnimationSet.setInterpolator(new DecelerateInterpolator());
    helpHeaderAnimationSet.setStartOffset(200);
    helpHeaderAnimationSet.setDuration(450);
    helpLayoutTextHeader.startAnimation(helpHeaderAnimationSet);

    AnimationSet helpContentAnimationSet = new AnimationSet(true);
    helpContentAnimationSet.addAnimation(new TranslateAnimation(0, 0, textMoveOffset, 0));
    helpContentAnimationSet.addAnimation(new AlphaAnimation(0, 1f));
    helpContentAnimationSet.setInterpolator(new DecelerateInterpolator());
    helpContentAnimationSet.setStartOffset(300);
    helpContentAnimationSet.setDuration(450);
    helpLayoutTextContent.startAnimation(helpContentAnimationSet);

    int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 65, getResources().getDisplayMetrics());
    TranslateAnimation helpLayoutBottomPanelSlideUp = new TranslateAnimation(0, 0, height, 0);
    helpLayoutBottomPanelSlideUp.setDuration(550);
    helpLayoutBottomPanelSlideUp.setStartOffset(500);
    helpLayoutBottomPanelSlideUp.setInterpolator(new DecelerateInterpolator());

    helpLayoutBottomPanel.startAnimation(helpLayoutBottomPanelSlideUp);
}
 
Example 20
Project: PeSanKita-android   File: MicrophoneRecorderView.java   Source Code and License Vote up 4 votes
public void hide(float x) {
  this.lastPositionX = x;

  float offset          = getOffset(x);
  int   widthAdjustment = getWidthAdjustment();

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment,
                                                        Animation.ABSOLUTE, widthAdjustment,
                                                        Animation.RELATIVE_TO_SELF, -.25f,
                                                        Animation.RELATIVE_TO_SELF, -.25f);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}